From 0d48c541a08cdffcffa2994d4c5fdb22d74ad189 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sat, 15 Nov 2025 00:27:30 +0100 Subject: [PATCH] Add tests runs to all packages --- .github/workflows/ci.yml | 4 +++- backend/api/package.json | 2 +- backend/email/jest.config.js | 26 ++++++++++++++++++++++++++ backend/email/package.json | 3 ++- backend/shared/jest.config.js | 26 ++++++++++++++++++++++++++ backend/shared/package.json | 3 ++- common/package.json | 2 +- package.json | 2 +- web/jest.config.js | 26 ++++++++++++++++++++++++++ web/package.json | 3 ++- 10 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 backend/email/jest.config.js create mode 100644 backend/shared/jest.config.js create mode 100644 web/jest.config.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 710e0a0..35a5f76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,9 @@ jobs: run: npm run lint - name: Run Jest tests - run: npm run test:coverage + env: + NEXT_PUBLIC_FIREBASE_ENV: DEV + run: yarn test # - name: Build app # env: diff --git a/backend/api/package.json b/backend/api/package.json index cdff831..6547486 100644 --- a/backend/api/package.json +++ b/backend/api/package.json @@ -21,7 +21,7 @@ "verify:dir": "npx eslint . --max-warnings 0", "regen-types": "cd ../supabase && make ENV=prod regen-types", "regen-types-dev": "cd ../supabase && make ENV=dev regen-types-dev", - "test": "jest" + "test": "jest --config jest.config.js" }, "engines": { "node": ">=20.0.0" diff --git a/backend/email/jest.config.js b/backend/email/jest.config.js new file mode 100644 index 0000000..08bc216 --- /dev/null +++ b/backend/email/jest.config.js @@ -0,0 +1,26 @@ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', + + rootDir: '.', + testMatch: [ + "/tests/**/*.test.ts", + "/tests/**/*.spec.ts" + ], + + moduleNameMapper: { + "^api/(.*)$": "/src/$1", + "^shared/(.*)$": "/../shared/src/$1", + "^common/(.*)$": "/../../common/src/$1", + "^email/(.*)$": "/../email/emails/$1" + }, + + moduleFileExtensions: ["ts", "js", "json"], + clearMocks: true, + + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.json' + } + } +}; diff --git a/backend/email/package.json b/backend/email/package.json index e82551a..b20261d 100644 --- a/backend/email/package.json +++ b/backend/email/package.json @@ -4,7 +4,8 @@ "private": true, "scripts": { "dev": "email dev --port 3001", - "build": "tsc -b" + "build": "tsc -b", + "test": "jest --config jest.config.js --passWithNoTests" }, "dependencies": { "@react-email/components": "0.0.33", diff --git a/backend/shared/jest.config.js b/backend/shared/jest.config.js new file mode 100644 index 0000000..08bc216 --- /dev/null +++ b/backend/shared/jest.config.js @@ -0,0 +1,26 @@ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', + + rootDir: '.', + testMatch: [ + "/tests/**/*.test.ts", + "/tests/**/*.spec.ts" + ], + + moduleNameMapper: { + "^api/(.*)$": "/src/$1", + "^shared/(.*)$": "/../shared/src/$1", + "^common/(.*)$": "/../../common/src/$1", + "^email/(.*)$": "/../email/emails/$1" + }, + + moduleFileExtensions: ["ts", "js", "json"], + clearMocks: true, + + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.json' + } + } +}; diff --git a/backend/shared/package.json b/backend/shared/package.json index 8d300f1..dabe3c6 100644 --- a/backend/shared/package.json +++ b/backend/shared/package.json @@ -6,7 +6,8 @@ "build": "tsc -b && yarn --cwd=../../common tsc-alias && tsc-alias", "compile": "tsc -b", "verify": "yarn --cwd=../.. verify", - "verify:dir": "npx eslint . --max-warnings 0" + "verify:dir": "npx eslint . --max-warnings 0", + "test": "jest --config jest.config.js --passWithNoTests" }, "sideEffects": false, "dependencies": { diff --git a/common/package.json b/common/package.json index aa4a2b8..8f7542f 100644 --- a/common/package.json +++ b/common/package.json @@ -7,7 +7,7 @@ "compile": "tsc -b", "verify": "yarn --cwd=.. verify", "verify:dir": "npx eslint . --max-warnings 0", - "test": "jest" + "test": "jest --config jest.config.js --passWithNoTests" }, "sideEffects": false, "dependencies": { diff --git a/package.json b/package.json index 2151249..78d3660 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "build-sync-android": "./scripts/build_sync_android.sh", "sync-android": "./scripts/sync_android.sh", "migrate": "./scripts/migrate.sh", - "test": "jest", + "test": "yarn workspaces run test", "test:coverage": "jest --coverage", "test:watch": "jest --watch", "test:update": "jest --updateSnapshot", diff --git a/web/jest.config.js b/web/jest.config.js new file mode 100644 index 0000000..08bc216 --- /dev/null +++ b/web/jest.config.js @@ -0,0 +1,26 @@ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', + + rootDir: '.', + testMatch: [ + "/tests/**/*.test.ts", + "/tests/**/*.spec.ts" + ], + + moduleNameMapper: { + "^api/(.*)$": "/src/$1", + "^shared/(.*)$": "/../shared/src/$1", + "^common/(.*)$": "/../../common/src/$1", + "^email/(.*)$": "/../email/emails/$1" + }, + + moduleFileExtensions: ["ts", "js", "json"], + clearMocks: true, + + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.json' + } + } +}; diff --git a/web/package.json b/web/package.json index 3c04490..be3457c 100644 --- a/web/package.json +++ b/web/package.json @@ -17,7 +17,8 @@ "format": "npx prettier --write .", "format-changed": "cd .. && git diff $(git merge-base --fork-point main) --name-only --diff-filter=d | xargs npx prettier -w", "verify": "(cd .. && yarn verify)", - "verify:dir": "npx prettier --check .; yarn lint --max-warnings 0; tsc --pretty --project tsconfig.json --noEmit" + "verify:dir": "npx prettier --check .; yarn lint --max-warnings 0; tsc --pretty --project tsconfig.json --noEmit", + "test": "jest --config jest.config.js --passWithNoTests" }, "dependencies": { "@floating-ui/react": "0.19.0",