parallel tests
This commit is contained in:
parent
73a45b81cc
commit
139a5fbef3
5 changed files with 61 additions and 228 deletions
|
|
@ -3,6 +3,10 @@ set -e
|
|||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# E2E tests use a separate database and port to allow parallel execution with backend tests
|
||||
E2E_PORT=${E2E_PORT:-8001}
|
||||
E2E_DATABASE_URL="postgresql+asyncpg://postgres:postgres@localhost:5432/arbret_e2e"
|
||||
|
||||
# Cleanup function to kill background processes
|
||||
cleanup() {
|
||||
kill $BACKEND_PID 2>/dev/null || true
|
||||
|
|
@ -18,34 +22,35 @@ if [ -f .env ]; then
|
|||
set +a
|
||||
fi
|
||||
|
||||
# Kill any existing backend
|
||||
pkill -f "uvicorn main:app" 2>/dev/null || true
|
||||
# Kill any existing e2e backend (on our specific port)
|
||||
pkill -f "uvicorn main:app --port $E2E_PORT" 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
# Seed the database with roles and test users
|
||||
# Seed the e2e database with roles and test users
|
||||
cd backend
|
||||
echo "Seeding database..."
|
||||
uv run python seed.py
|
||||
echo "Seeding e2e database..."
|
||||
DATABASE_URL="$E2E_DATABASE_URL" uv run python seed.py
|
||||
cd ..
|
||||
|
||||
# Start backend (SECRET_KEY should be set via .envrc or environment)
|
||||
# Start backend for e2e tests (uses e2e database and separate port)
|
||||
cd backend
|
||||
uv run uvicorn main:app --port 8000 --log-level warning &
|
||||
DATABASE_URL="$E2E_DATABASE_URL" uv run uvicorn main:app --port $E2E_PORT --log-level warning &
|
||||
BACKEND_PID=$!
|
||||
cd ..
|
||||
|
||||
# Wait for backend
|
||||
sleep 2
|
||||
|
||||
# Generate API types from OpenAPI schema
|
||||
echo "Generating API types..."
|
||||
# Generate API types from OpenAPI schema (using e2e backend)
|
||||
echo "Generating API types from e2e backend..."
|
||||
cd frontend
|
||||
npm run generate-api-types
|
||||
npx openapi-typescript "http://localhost:$E2E_PORT/openapi.json" -o app/generated/api.ts
|
||||
cd ..
|
||||
|
||||
# Run tests (suppress Node.js color warnings)
|
||||
# If TEST argument is provided, use it as a file pattern
|
||||
# Run tests with e2e-specific backend URL
|
||||
# The frontend will connect to our e2e backend on $E2E_PORT
|
||||
cd frontend
|
||||
export NEXT_PUBLIC_API_URL="http://localhost:$E2E_PORT"
|
||||
if [ -n "$1" ]; then
|
||||
NODE_NO_WARNINGS=1 npx playwright test "$1"
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue