From 897481417d432c73ed1224b4f9167b4a26431343 Mon Sep 17 00:00:00 2001 From: daxantz Date: Mon, 22 Sep 2025 18:30:10 -0400 Subject: [PATCH 1/5] add CI test workflow --- .github/workflows/testing.yml | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..e97d036 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,52 @@ +name: Unit tests + +on: [pull_request] + +jobs: + tests: + runs-on: ubuntu-latest + + services: + test-db: + image: postgres:15 + ports: + - 5433:5432 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: Callofduty2497 + POSTGRES_DB: valetapptest + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Wait for Postgres to be ready + run: | + until pg_isready -h localhost -p 5433; do + echo "Waiting for Postgres..." + sleep 2 + done + + - name: Run Prisma migrate + env: + DATABASE_URL: postgres://postgres:Callofduty2497@localhost:5433/valetapptest + run: npx prisma migrate deploy + + - name: Run tests + env: + NODE_ENV: test + DATABASE_URL: postgres://postgres:Callofduty2497@localhost:5433/valetapptest + run: npm test From 46f5ea05c191d3d443963e53f048a14cd749d9dc Mon Sep 17 00:00:00 2001 From: daxantz Date: Mon, 22 Sep 2025 18:35:04 -0400 Subject: [PATCH 2/5] fix jest config for ci --- jest.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index 8676055..6b49379 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,5 @@ -import { createDefaultPreset } from 'ts-jest' +/* eslint-disable @typescript-eslint/no-var-requires */ +const { createDefaultPreset } = require('ts-jest/presets') const tsJestTransformCfg = createDefaultPreset().transform From a4da6b4f6fedb2cb448f6c360128600119758aa8 Mon Sep 17 00:00:00 2001 From: daxantz Date: Mon, 22 Sep 2025 18:38:16 -0400 Subject: [PATCH 3/5] fix jest config to use common js --- jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index 6b49379..94f2542 100644 --- a/jest.config.js +++ b/jest.config.js @@ -15,4 +15,4 @@ const config = { clearMocks: true, // auto-clear mocks between tests } -export default config +module.exports = config From b9ff4d922694beebe777434c4f912a5d123bfce6 Mon Sep 17 00:00:00 2001 From: daxantz Date: Mon, 22 Sep 2025 18:41:02 -0400 Subject: [PATCH 4/5] fix jest config --- jest.config.js | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/jest.config.js b/jest.config.js index 94f2542..34a5229 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,18 +1,7 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { createDefaultPreset } = require('ts-jest/presets') - -const tsJestTransformCfg = createDefaultPreset().transform - -/** @type {import("jest").Config} */ -const config = { +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', testEnvironment: 'node', - transform: { - ...tsJestTransformCfg, - }, - testMatch: ['**/__tests__/**/*.test.ts'], // look for tests in __tests__ - setupFilesAfterEnv: ['/jest.setup.ts'], // optional setup (Prisma, DB, etc.) - moduleFileExtensions: ['ts', 'js', 'json'], - clearMocks: true, // auto-clear mocks between tests + moduleFileExtensions: ['ts', 'js', 'json', 'node'], + roots: ['/src'], } - -module.exports = config From 77f18b9ebafdb2ba77c66dacd784d5fe91c12b29 Mon Sep 17 00:00:00 2001 From: daxantz Date: Mon, 22 Sep 2025 18:45:17 -0400 Subject: [PATCH 5/5] added correct path for tests to config --- jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index 34a5229..d7b119f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,5 +3,5 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'node', moduleFileExtensions: ['ts', 'js', 'json', 'node'], - roots: ['/src'], + testMatch: ['**/__tests__/**/*.(test|spec).ts', '**/?(*.)+(test|spec).ts'], }