Make yarn dev:isolated run like yarn:test:services

This commit is contained in:
MartinBraquet
2026-06-06 14:55:43 +02:00
parent ed20465e3e
commit 9d8f059205
8 changed files with 120 additions and 160 deletions

View File

@@ -160,6 +160,10 @@ Start the development server:
yarn dev
```
Note: the dev remote server is not available until further notice (to save money). The above command will start a local
server instead (same as `yarn dev:isolated` below). You'll have to set up Firebase and Supabase first (see below).
Contact us if you need help; we may spin up the dev remote server for you.
Once the server is running, visit http://localhost:3000 to start using the app. You can sign up and visit the profiles;
you should see a few synthetic profiles.

View File

@@ -577,7 +577,7 @@ yarn test:e2e:dev --debug tests/e2e/web/specs/signUp.spec.ts
### 1. Start services once
```bash
yarn test:e2e:services
yarn dev:isolated
```
This starts Firebase emulators, the backend API, and Next.js in one terminal.

View File

@@ -15,7 +15,7 @@
"build-sync-android": "./scripts/build_sync_android.sh",
"build-web-view": "./scripts/build_web_view.sh",
"clean-install": "./scripts/install.sh",
"dev": "./scripts/run_local.sh dev",
"dev": "yarn dev:isolated",
"dev:isolated": "./scripts/run_local_isolated.sh",
"emulate": "firebase emulators:start --only auth,storage --project compass-57c3c",
"postinstall": "./scripts/post_install.sh",
@@ -41,7 +41,6 @@
"test:e2e:debug": "./scripts/e2e.sh --debug",
"test:e2e:dev": "./scripts/e2e-dev.sh",
"test:e2e:dev:ui": "yarn test:e2e:dev --ui",
"test:e2e:services": "./scripts/e2e_services.sh",
"test:e2e:ui": "./scripts/e2e.sh --ui",
"test:update": "yarn workspaces run test --updateSnapshot",
"test:watch": "yarn workspaces run test --watch",
@@ -120,7 +119,7 @@
"prettier-plugin-packagejson": "3.0.0",
"prettier-plugin-sql": "0.19.2",
"prettier-plugin-tailwindcss": "0.2.8",
"supabase": "2.76.9",
"supabase": "2.105.0",
"ts-jest": "29.4.6",
"ts-node": "10.9.1",
"tsc-alias": "1.8.2",

View File

@@ -34,7 +34,7 @@ check_services() {
if [ $missing -eq 1 ]; then
echo ""
echo "Start everything with: yarn test:e2e:services"
echo "Start everything with: yarn dev:isolated"
echo "Or start full clean run: yarn test:e2e"
exit 1
fi

View File

@@ -1,40 +0,0 @@
#!/bin/bash
# TODO: is the same as run_local_isolated.sh apart from the process cleanup. See if they can be merged.
# Test services and isolated dev services are the same for now, but they may diverge in the future.
set -euo pipefail
# Change to project root
cd "$(dirname "$0")"/..
export NEXT_PUBLIC_ISOLATED_ENV=true
export $(cat .env.local | grep -v '^#' | xargs)
export $(cat .env.test | grep -v '^#' | xargs)
# Ensure Supabase local stack is running; if not, reset/start it
STATUS_JSON=$(supabase status --output json 2>/dev/null || echo '')
API_URL=$(echo "$STATUS_JSON" | jq -r '.API_URL // empty')
if [ -z "$API_URL" ]; then
echo "Supabase is not running. Bootstrapping local stack with: yarn test:db:reset"
yarn test:db:reset
STATUS_JSON=$(supabase status --output json)
fi
export NEXT_PUBLIC_SUPABASE_URL=$(echo "$STATUS_JSON" | jq -r '.API_URL')
export NEXT_PUBLIC_SUPABASE_ANON_KEY=$(echo "$STATUS_JSON" | jq -r '.ANON_KEY')
export DATABASE_URL=$(echo "$STATUS_JSON" | jq -r '.DB_URL')
for var in NEXT_PUBLIC_SUPABASE_URL NEXT_PUBLIC_SUPABASE_ANON_KEY DATABASE_URL; do
if [ -z "${!var}" ] || [ "${!var}" = "null" ]; then
echo "Error: $var is not set or null" >&2
exit 1
fi
done
# Build backend (required?)
./scripts/build_api.sh
concurrently --names 'firebase,api,web' 'yarn emulate' 'yarn --cwd=backend/api dev' 'yarn --cwd=web dev'

View File

@@ -1,6 +1,6 @@
#!/bin/bash
cd "$(dirname "$0")"/..
# Note: Test services and isolated dev services are the same for now, but they may diverge in the future.
# Run the web app locally in full isolation (database, storage and authentication all stored locally)
# What runs on each port?
@@ -24,50 +24,14 @@ NC='\033[0m'
print_status() { echo -e "${GREEN}[E2E-DEV]${NC} $1"; }
print_error() { echo -e "${RED}[ERROR]${NC} $1"; }
# Clean ghost processes
kill_ghosts() {
for p in 3000 4000 4400 4500 8088 9099 9199; do
pids=$(lsof -ti :$p 2>/dev/null)
if [ -n "$pids" ]; then
kill $pids || true
fi
done
}
kill_ghosts
set -euo pipefail
# Function to clean up background processes
cleanup() {
print_status "Cleaning up..."
# Change to project root
cd "$(dirname "$0")"/..
# Stop Firebase emulators
./scripts/firebase_stop.sh
# Kill all background processes
for pid in "${PIDS[@]:-}"; do
if kill -0 "$pid" 2>/dev/null; then
kill "$pid" 2>/dev/null || true
wait "$pid" 2>/dev/null || true
fi
done
kill_ghosts
# Stop Docker containers
if [ "${SKIP_DB_CLEANUP:-}" != "true" ]; then
print_status "Stopping test database..."
docker compose -f scripts/docker-compose.test.yml down -v
fi
sleep 2
print_status "Cleanup complete"
}
# Trap EXIT, INT, TERM to run cleanup automatically
trap cleanup EXIT INT TERM
export NEXT_PUBLIC_ISOLATED_ENV=true
export $(cat .env.local | grep -v '^#' | xargs)
export $(cat .env.test | grep -v '^#' | xargs)
# Ensure Supabase local stack is running; if not, reset/start it
@@ -84,25 +48,63 @@ export NEXT_PUBLIC_SUPABASE_URL=$(echo "$STATUS_JSON" | jq -r '.API_URL')
export NEXT_PUBLIC_SUPABASE_ANON_KEY=$(echo "$STATUS_JSON" | jq -r '.ANON_KEY')
export DATABASE_URL=$(echo "$STATUS_JSON" | jq -r '.DB_URL')
echo $NEXT_PUBLIC_SUPABASE_URL
echo $NEXT_PUBLIC_SUPABASE_ANON_KEY
echo $DATABASE_URL
for var in NEXT_PUBLIC_SUPABASE_URL NEXT_PUBLIC_SUPABASE_ANON_KEY DATABASE_URL; do
if [ -z "${!var}" ] || [ "${!var}" = "null" ]; then
echo "Error: $var is not set or null" >&2
exit 1
fi
done
# Start servers in background and store their PIDs
PIDS=()
npx nyc --reporter=lcov yarn --cwd=web serve & PIDS+=($!)
npx nyc --reporter=lcov yarn --cwd=backend/api dev & PIDS+=($!)
yarn emulate & PIDS+=($!)
npx wait-on http://localhost:3000
# Build backend (required?)
#./scripts/build_api.sh
echo ""
echo "✅ Isolated web app fully running and ready!"
echo " Starting isolated web app..."
echo " Useful links:"
echo " - Front end: http://127.0.0.1:3000"
echo " - Back end: http://127.0.0.1:8080"
echo " - Supabase UI: http://127.0.0.1:54323"
echo " - Firebase UI: http://127.0.0.1:4000"
echo ""
read -p "Press enter to exit..." < /dev/tty
exit ${TEST_FAILED:-0}
concurrently --names 'firebase,api,web' 'yarn emulate' 'yarn --cwd=backend/api dev' 'yarn --cwd=web dev'
#kill_ghosts() {
# for p in 3000 4000 4400 4500 8088 9099 9199; do
# pids=$(lsof -ti :$p 2>/dev/null)
# if [ -n "$pids" ]; then
# kill $pids || true
# fi
# done
#}
#
## Function to clean up background processes
#cleanup() {
# print_status "Cleaning up..."
#
# # Stop Firebase emulators
# ./scripts/firebase_stop.sh
#
# # Kill all background processes
# for pid in "${PIDS[@]:-}"; do
# if kill -0 "$pid" 2>/dev/null; then
# kill "$pid" 2>/dev/null || true
# wait "$pid" 2>/dev/null || true
# fi
# done
#
# kill_ghosts
#
# # Stop Docker containers
# if [ "${SKIP_DB_CLEANUP:-}" != "true" ]; then
# print_status "Stopping test database..."
# docker compose -f scripts/docker-compose.test.yml down -v
# fi
#
# sleep 2
#
# print_status "Cleanup complete"
#}
#
## Trap EXIT, INT, TERM to run cleanup automatically
#trap cleanup EXIT INT TERM

View File

@@ -1,4 +1,5 @@
import axios from 'axios'
import {config} from '../web/SPEC_CONFIG'
export async function firebaseLoginEmailPassword(
@@ -85,7 +86,7 @@ export async function firebaseSignUp(email: string, password: string) {
return await getUserId(email, password)
}
if (err.code === 'ECONNREFUSED') return
// throw Error('Firebase emulator not running. Start it with:\n yarn test:e2e:services\n')
// throw Error('Firebase emulator not running. Start it with:\n yarn dev:isolated\n')
console.log(err)
throw err
}

114
yarn.lock
View File

@@ -4756,6 +4756,46 @@
dependencies:
tslib "2.8.1"
"@supabase/cli-darwin-arm64@2.105.0":
version "2.105.0"
resolved "https://registry.yarnpkg.com/@supabase/cli-darwin-arm64/-/cli-darwin-arm64-2.105.0.tgz#7d2ad2fd23aac2f603609a9955a50dca10b5632a"
integrity sha512-ptlLrggNCq7dndvY7ce0MIvCZRnAYXeyKC0H7c4DqQmCbOPZgSwD5a4E3RPrZS6TLeJPG7XhpuJarAU5PTf/9w==
"@supabase/cli-darwin-x64@2.105.0":
version "2.105.0"
resolved "https://registry.yarnpkg.com/@supabase/cli-darwin-x64/-/cli-darwin-x64-2.105.0.tgz#7eb2cc4207e44648a94769185712bb17b52b3b67"
integrity sha512-kJDYyy3UkXd4hDzo+duOzUk8yDqLEit8d/clBCiXNQFSJf96QCnG2iyrzT4dCDUk8UB3+g9xL1mH2EEuPHj7oA==
"@supabase/cli-linux-arm64-musl@2.105.0":
version "2.105.0"
resolved "https://registry.yarnpkg.com/@supabase/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.105.0.tgz#d588fc786bed166dfe53c9bb83a58b805a58cbda"
integrity sha512-45vxbXRwe/JUAjyvQ8oKO2o44IK3GunlVqeIWGzcDgaeMg5XO4x0i9+NGPvOvvhyMB4bgJ3cMxh/ovl1AM0GZA==
"@supabase/cli-linux-arm64@2.105.0":
version "2.105.0"
resolved "https://registry.yarnpkg.com/@supabase/cli-linux-arm64/-/cli-linux-arm64-2.105.0.tgz#c022b4822520ca0ded0cdeda6a9b97e27564f78c"
integrity sha512-cdHgfIFElYkAjrp0aJPlQPTqQ9doSxB4qRswlGNsSYaLlK5Ns78rXsB7G71RRnyrzb41C183osRhVENWVrnK/w==
"@supabase/cli-linux-x64-musl@2.105.0":
version "2.105.0"
resolved "https://registry.yarnpkg.com/@supabase/cli-linux-x64-musl/-/cli-linux-x64-musl-2.105.0.tgz#1335bbca58857d21b08f2da200c25425c181ebe3"
integrity sha512-VnHn1NPn9Ov81BXFOx6FpHxbBT5e3ObaUxO7DR+LDGjh2wfMUj4E6Y863w+r0HJk0hi0mRH7u0U0dOrbBp4E+w==
"@supabase/cli-linux-x64@2.105.0":
version "2.105.0"
resolved "https://registry.yarnpkg.com/@supabase/cli-linux-x64/-/cli-linux-x64-2.105.0.tgz#5273d05f7deb7652fab88d8cbc8dd98a2c125365"
integrity sha512-rj1iU0h4EJaanx72eJtipiXczAY3gug9qxo62MYUZg2X1aaegFtyMS83fmjC7YlduW2Cu+zvgWoyTlA6R5Ndzg==
"@supabase/cli-windows-arm64@2.105.0":
version "2.105.0"
resolved "https://registry.yarnpkg.com/@supabase/cli-windows-arm64/-/cli-windows-arm64-2.105.0.tgz#c5eaa32f38714ca07ee6d2dec4ce4051fb60aba5"
integrity sha512-b5xQ5dVkARZTBiSwLpPbwffRHvVDcO3ZvAtzz54J44KQdLD0TSrgoXZJBrI4Y3ggmG70EiITKPL8+rT6ptjXsQ==
"@supabase/cli-windows-x64@2.105.0":
version "2.105.0"
resolved "https://registry.yarnpkg.com/@supabase/cli-windows-x64/-/cli-windows-x64-2.105.0.tgz#e4481d5f72dc8f08838e5c25055bc15a2ecb4d27"
integrity sha512-QmfqDQJ58ba/9+vzM8HJQsa/rY6OdtaaaAmPKwCMd8JUQ7758p8sydYe1vXTb4CCPdvk9qW2d/Dh54ucH4SPwg==
"@supabase/functions-js@2.98.0":
version "2.98.0"
resolved "https://registry.yarnpkg.com/@supabase/functions-js/-/functions-js-2.98.0.tgz#2dd25b32d6cf891b77341d97408fc05351048a50"
@@ -6892,17 +6932,6 @@ bignumber.js@^9.0.0:
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c"
integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==
bin-links@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/bin-links/-/bin-links-6.0.0.tgz#0245114374463a694e161a1e65417e7939ab2eba"
integrity sha512-X4CiKlcV2GjnCMwnKAfbVWpHa++65th9TuzAEYtZoATiOE2DQKhSp4CJlyLoTqdhBKlXjpXjCTYPNNFS33Fi6w==
dependencies:
cmd-shim "^8.0.0"
npm-normalize-package-bin "^5.0.0"
proc-log "^6.0.0"
read-cmd-shim "^6.0.0"
write-file-atomic "^7.0.0"
binary-extensions@^2.0.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522"
@@ -7475,11 +7504,6 @@ clsx@2.1.1, clsx@^2.0.0, clsx@^2.1.1:
resolved "https://registry.yarnpkg.com/clsx/-/clsx-2.1.1.tgz#eed397c9fd8bd882bfb18deab7102049a2f32999"
integrity sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==
cmd-shim@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/cmd-shim/-/cmd-shim-8.0.0.tgz#5be238f22f40faf3f7e8c92edc3f5d354f7657b2"
integrity sha512-Jk/BK6NCapZ58BKUxlSI+ouKRbjH1NLZCgJkYoab+vEHUY3f6OzpNBN9u7HFSv9J6TRDGs4PLOHezoKGaFRSCA==
co@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
@@ -11128,7 +11152,7 @@ https-proxy-agent@^5.0.0:
agent-base "6"
debug "4"
https-proxy-agent@^7.0.0, https-proxy-agent@^7.0.2, https-proxy-agent@^7.0.6:
https-proxy-agent@^7.0.0, https-proxy-agent@^7.0.6:
version "7.0.6"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz#da8dfeac7da130b05c2ba4b59c9b6cd66611a6b9"
integrity sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==
@@ -14139,11 +14163,6 @@ npm-normalize-package-bin@^3.0.0:
resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz#25447e32a9a7de1f51362c61a559233b89947832"
integrity sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==
npm-normalize-package-bin@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-5.0.0.tgz#2b207ff260f2e525ddce93356614e2f736728f89"
integrity sha512-CJi3OS4JLsNMmr2u07OJlhcrPxCeOeP/4xq67aWNai6TNWWbTrlNDgl8NcFKVlcBKp18GPj+EzbNIgrBfZhsag==
npm-package-arg@^11.0.0:
version "11.0.3"
resolved "https://registry.yarnpkg.com/npm-package-arg/-/npm-package-arg-11.0.3.tgz#dae0c21199a99feca39ee4bfb074df3adac87e2d"
@@ -15176,11 +15195,6 @@ proc-log@^5.0.0:
resolved "https://registry.yarnpkg.com/proc-log/-/proc-log-5.0.0.tgz#e6c93cf37aef33f835c53485f314f50ea906a9d8"
integrity sha512-Azwzvl90HaF0aCz1JrDdXQykFakSSNPaPoiZ9fm5qJIMHioDZEi7OAdRwSm6rSoPtY3Qutnm3L7ogmg3dc+wbQ==
proc-log@^6.0.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/proc-log/-/proc-log-6.1.0.tgz#18519482a37d5198e231133a70144a50f21f0215"
integrity sha512-iG+GYldRf2BQ0UDUAd6JQ/RwzaQy6mXmsk/IzlYyal4A4SNFw54MeH4/tLkF4I5WoWG9SQwuqWzS99jaFQHBuQ==
process-nextick-args@~2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
@@ -15835,11 +15849,6 @@ read-cache@^1.0.0:
dependencies:
pify "^2.3.0"
read-cmd-shim@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-6.0.0.tgz#98f5c8566e535829f1f8afb1595aaf05fd0f3970"
integrity sha512-1zM5HuOfagXCBWMN83fuFI/x+T/UhZ7k+KIzhrHXcQoeX5+7gmaDYjELQHmmzIodumBHeByBJT4QYS7ufAgs7A==
read-pkg-up@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07"
@@ -17338,15 +17347,19 @@ sucrase@^3.35.0:
tinyglobby "^0.2.11"
ts-interface-checker "^0.1.9"
supabase@2.76.9:
version "2.76.9"
resolved "https://registry.yarnpkg.com/supabase/-/supabase-2.76.9.tgz#79b1d1f78e80b54f71ddce67078f89b577573860"
integrity sha512-BHQ9kSetU7QUm9eLUzGtzlIvkktVnQZ8ypar8Bck9PQZdRE/ugXLLHBg/qqlWTxYRS7QV7Vn/rGLVhWclVMm+g==
dependencies:
bin-links "^6.0.0"
https-proxy-agent "^7.0.2"
node-fetch "^3.3.2"
tar "7.5.7"
supabase@2.105.0:
version "2.105.0"
resolved "https://registry.yarnpkg.com/supabase/-/supabase-2.105.0.tgz#f0e05df4c74aabc21621389702b690f11415e969"
integrity sha512-UB2aFLYAVujTQsZ9l+aCbDfLNaZApZucByRNP/1j0L1pXXzFhSgEyZSrvHSUO5LIvOb09AGHWishL/usVTuHTg==
optionalDependencies:
"@supabase/cli-darwin-arm64" "2.105.0"
"@supabase/cli-darwin-x64" "2.105.0"
"@supabase/cli-linux-arm64" "2.105.0"
"@supabase/cli-linux-arm64-musl" "2.105.0"
"@supabase/cli-linux-x64" "2.105.0"
"@supabase/cli-linux-x64-musl" "2.105.0"
"@supabase/cli-windows-arm64" "2.105.0"
"@supabase/cli-windows-x64" "2.105.0"
superstatic@^10.0.0:
version "10.0.0"
@@ -17547,17 +17560,6 @@ tar-stream@^3.0.0, tar-stream@^3.1.5:
fast-fifo "^1.2.0"
streamx "^2.15.0"
tar@7.5.7:
version "7.5.7"
resolved "https://registry.yarnpkg.com/tar/-/tar-7.5.7.tgz#adf99774008ba1c89819f15dbd6019c630539405"
integrity sha512-fov56fJiRuThVFXD6o6/Q354S7pnWMJIVlDBYijsTNx6jKSE4pvrDTs6lUnmGvNyfJwFQQwWy3owKz1ucIhveQ==
dependencies:
"@isaacs/fs-minipass" "^4.0.0"
chownr "^3.0.0"
minipass "^7.1.2"
minizlib "^3.1.0"
yallist "^5.0.0"
tar@^6.1.11:
version "6.2.1"
resolved "https://registry.yarnpkg.com/tar/-/tar-6.2.1.tgz#717549c541bc3c2af15751bea94b1dd068d4b03a"
@@ -18827,14 +18829,6 @@ write-file-atomic@^4.0.2:
imurmurhash "^0.1.4"
signal-exit "^3.0.7"
write-file-atomic@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-7.0.0.tgz#f89def4f223e9bf8b06cc6fdb12bda3a917505c7"
integrity sha512-YnlPC6JqnZl6aO4uRc+dx5PHguiR9S6WeoLtpxNT9wIG+BDya7ZNE1q7KOjVgaA73hKhKLpVPgJ5QA9THQ5BRg==
dependencies:
imurmurhash "^0.1.4"
signal-exit "^4.0.1"
ws@8.17.1:
version "8.17.1"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b"