Skip to content

Commit 7d02649

Browse files
committed
test: introduce foundation for automated server tests
- Add shared test infrastructure - Configure backend and microservice test setup Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent eba296c commit 7d02649

22 files changed

Lines changed: 888 additions & 443 deletions

File tree

.env.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
NODE_ENV=test
2+
DB_HOST=localhost
3+
DB_PORT=5434
4+
DB_USER=postgres
5+
DB_PASSWORD=example

.github/workflows/server-tests.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Server Tests
2+
3+
on:
4+
pull_request:
5+
# Only trigger when relevant files change to save CI minutes
6+
paths-ignore:
7+
- 'frontend/**'
8+
- '**.md'
9+
- '.gitignore'
10+
- '.editorconfig'
11+
- '**/.eslintrc*'
12+
- '.prettierrc'
13+
- '.prettierignore'
14+
- 'LICENSE'
15+
16+
# Automatically cancel in-progress runs if you push new code to the same PR
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
test:
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 30
28+
29+
services:
30+
postgres:
31+
image: postgres:14-alpine
32+
env:
33+
POSTGRES_USER: postgres
34+
POSTGRES_PASSWORD: example
35+
POSTGRES_DB: postgres
36+
ports:
37+
- 5432:5432
38+
options: >-
39+
--health-cmd "pg_isready -U postgres"
40+
--health-interval 2s
41+
--health-timeout 5s
42+
--health-retries 15
43+
postgres -c wal_level=logical
44+
45+
env:
46+
NODE_ENV: test
47+
DB_HOST: localhost
48+
DB_PORT: 5432
49+
DB_USER: postgres
50+
DB_PASSWORD: example
51+
52+
steps:
53+
- name: Check out repository code
54+
uses: actions/checkout@v4
55+
56+
- name: Setup Node and cache pnpm
57+
uses: actions/setup-node@v4
58+
with:
59+
node-version: 20
60+
cache: 'pnpm' # Built-in caching for faster runs
61+
62+
- name: Install dependencies
63+
run: |
64+
corepack enable
65+
pnpm i --frozen-lockfile
66+
67+
- name: Prepare test database
68+
run: SEQUIN_BOOTSTRAP=1 ./scripts/prepare-test-template-db.sh
69+
70+
- name: Run server tests
71+
run: pnpm test:server

backend/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
"dotenv": "8.2.0",
9494
"dotenv-expand": "^8.0.3",
9595
"emoji-dictionary": "^1.0.11",
96-
"erlpack": "^0.1.4",
9796
"express": "4.17.1",
9897
"express-oauth2-jwt-bearer": "^1.7.4",
9998
"express-rate-limit": "6.5.1",
@@ -132,7 +131,6 @@
132131
"uuid": "^9.0.0",
133132
"validator": "^13.7.0",
134133
"verify-github-webhook": "^1.0.1",
135-
"zlib-sync": "^0.1.8",
136134
"zod": "^4.3.6"
137135
},
138136
"private": true,

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
{
22
"private": true,
33
"scripts": {
4-
"prepare": "husky"
4+
"prepare": "husky",
5+
"test": "vitest run",
6+
"test:server": "vitest run --project server",
7+
"test:changed": "vitest --changed",
8+
"test:watch": "vitest"
59
},
610
"devDependencies": {
711
"@commitlint/cli": "^19.8.0",
812
"@commitlint/config-conventional": "^19.8.0",
9-
"husky": "^9.1.7"
13+
"husky": "^9.1.7",
14+
"vite": "6.3.5",
15+
"vitest": "4.1.7"
1016
},
1117
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b"
1218
}

0 commit comments

Comments
 (0)