Skip to content

Commit 279b2ce

Browse files
seed function for running e2e in a more consistent data
1 parent f8cf953 commit 279b2ce

File tree

8 files changed

+623
-7
lines changed

8 files changed

+623
-7
lines changed

compose.e2e.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
services:
2+
app:
3+
build:
4+
context: ./
5+
dockerfile: dev.Containerfile
6+
image: apparaatti_dev
7+
environment:
8+
- DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
9+
- PORT=8000
10+
- IN_E2E=true
11+
- TEST_CURRENT_DATE=2026-02-20
12+
- NODE_ENV=test
13+
volumes:
14+
- ./:/opt/app-root/src
15+
ports:
16+
- 3000:3000
17+
- 8000:8000
18+
container_name: apparaatti_e2e
19+
networks:
20+
- localhost-network
21+
depends_on:
22+
- db
23+
- redis
24+
25+
db:
26+
image: docker.io/postgres:15.8-alpine
27+
environment:
28+
- PGDATA=/data
29+
- POSTGRES_PASSWORD=postgres
30+
ports:
31+
- 5433:5432
32+
volumes:
33+
- pg_data_e2e:/data
34+
container_name: apparaatti_e2e_db
35+
networks:
36+
- localhost-network
37+
38+
redis:
39+
image: redis:7-alpine
40+
container_name: apparaatti_e2e_redis
41+
networks:
42+
- localhost-network
43+
44+
networks:
45+
localhost-network:
46+
driver: bridge
47+
driver_opts:
48+
com.docker.network.bridge.host_binding_ipv4: "127.0.0.1"
49+
volumes:
50+
pg_data_e2e:

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"prod": "NODE_ENV=production node --no-warnings --experimental-strip-types src/server/index.ts",
99
"dev": "NODE_ENV=development concurrently \"nodemon --verbose --ignore '*cypress*' --exec node --no-warnings --experimental-strip-types src/server/index.ts\" \"vite\"",
1010
"e2e": "sh ./scripts/run-cypress.sh",
11+
"e2e:up": "docker compose -f compose.e2e.yaml up",
12+
"e2e:down": "docker compose -f compose.e2e.yaml down",
1113
"tsc": "tsc --noEmit",
1214
"test": "vitest",
1315
"lint": "eslint 'src/**/*.{ts,tsx}'",

scripts/run-cypress.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
#!/bin/sh
22
set -e
33

4+
# Check if E2E environment is already running
5+
if curl -fsS http://localhost:3000/api/ping >/dev/null 2>&1; then
6+
echo "E2E environment already running, using existing setup..."
7+
echo "Running Cypress tests..."
8+
npx cypress run --spec cypress/e2e/ping.cy.ts
9+
exit 0
10+
fi
11+
412
cleanup() {
513
echo "Stopping Docker Compose services..."
6-
docker compose down
14+
docker compose -f compose.e2e.yaml down
715
}
816

917
trap cleanup EXIT INT TERM
1018

11-
echo "Starting Docker Compose services..."
12-
docker compose up -d --build app db redis
19+
echo "Starting E2E Docker Compose services..."
20+
docker compose -f compose.e2e.yaml up -d --build app db redis
1321

1422
echo "Waiting for app readiness at http://localhost:3000/api/ping..."
1523
retries=60

0 commit comments

Comments
 (0)