Add tests runs to all packages

This commit is contained in:
MartinBraquet
2025-11-15 00:27:30 +01:00
parent 8928cd1667
commit 0d48c541a0
10 changed files with 90 additions and 7 deletions

View File

@@ -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:

View File

@@ -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"

View File

@@ -0,0 +1,26 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
rootDir: '.',
testMatch: [
"<rootDir>/tests/**/*.test.ts",
"<rootDir>/tests/**/*.spec.ts"
],
moduleNameMapper: {
"^api/(.*)$": "<rootDir>/src/$1",
"^shared/(.*)$": "<rootDir>/../shared/src/$1",
"^common/(.*)$": "<rootDir>/../../common/src/$1",
"^email/(.*)$": "<rootDir>/../email/emails/$1"
},
moduleFileExtensions: ["ts", "js", "json"],
clearMocks: true,
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.json'
}
}
};

View File

@@ -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",

View File

@@ -0,0 +1,26 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
rootDir: '.',
testMatch: [
"<rootDir>/tests/**/*.test.ts",
"<rootDir>/tests/**/*.spec.ts"
],
moduleNameMapper: {
"^api/(.*)$": "<rootDir>/src/$1",
"^shared/(.*)$": "<rootDir>/../shared/src/$1",
"^common/(.*)$": "<rootDir>/../../common/src/$1",
"^email/(.*)$": "<rootDir>/../email/emails/$1"
},
moduleFileExtensions: ["ts", "js", "json"],
clearMocks: true,
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.json'
}
}
};

View File

@@ -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": {

View File

@@ -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": {

View File

@@ -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",

26
web/jest.config.js Normal file
View File

@@ -0,0 +1,26 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
rootDir: '.',
testMatch: [
"<rootDir>/tests/**/*.test.ts",
"<rootDir>/tests/**/*.spec.ts"
],
moduleNameMapper: {
"^api/(.*)$": "<rootDir>/src/$1",
"^shared/(.*)$": "<rootDir>/../shared/src/$1",
"^common/(.*)$": "<rootDir>/../../common/src/$1",
"^email/(.*)$": "<rootDir>/../email/emails/$1"
},
moduleFileExtensions: ["ts", "js", "json"],
clearMocks: true,
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.json'
}
}
};

View File

@@ -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",