-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathjest.config.js
More file actions
65 lines (61 loc) · 2.22 KB
/
Copy pathjest.config.js
File metadata and controls
65 lines (61 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const nextJest = require('next/jest');
const createJestConfig = nextJest({ dir: './' });
/** @type {import('jest').Config} */
const customJestConfig = {
testEnvironment: 'jest-environment-jsdom',
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
},
// e2e/ holds Playwright specs (its own runner, see playwright.config.ts) —
// Jest's default testMatch would otherwise pick up *.spec.ts under it too.
// server/ is a separate Node.js service with its own package.json and its
// own test runner (`node --test`, see server/package.json) — it isn't
// part of the Next.js app and shouldn't be swept up by this config.
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/e2e/',
'<rootDir>/server/',
// setup-providers.tsx is a shared render helper, not a test file.
// Without this pattern, jest's default testMatch would treat it as a
// test suite with zero tests and emit a "your test suite must contain
// at least one test" warning, breaking `npx jest --ci`.
// Matches __tests__/setup-providers.tsx and any future non-test
// helpers in the same dir (e.g. setup-providers-helpers.tsx).
// Update this regex if you add another non-test helper at __tests__/.
'<rootDir>/__tests__/setup-providers[^/]*\\.tsx',
],
// Issue #108: enforce minimum coverage thresholds
coverageThreshold: {
global: {
branches: 70,
functions: 80,
lines: 80,
statements: 80,
},
},
// Output coverage reports to the coverage/ directory
coverageDirectory: 'coverage',
collectCoverageFrom: [
'app/**/*.{ts,tsx}',
'components/**/*.{ts,tsx}',
'hooks/**/*.{ts,tsx}',
'lib/**/*.{ts,tsx}',
'context/**/*.{ts,tsx}',
'!**/*.d.ts',
'!**/*.stories.{ts,tsx}',
'!**/node_modules/**',
],
};
// Wrap to override transformIgnorePatterns after next/jest applies its defaults
async function jestConfig() {
const nextJestConfig = await createJestConfig(customJestConfig)();
return {
...nextJestConfig,
transformIgnorePatterns: [
'/node_modules/(?!(next-intl|use-intl|@formatjs|intl-messageformat)/)',
'^.+\\.module\\.(css|sass|scss)$',
],
};
}
module.exports = jestConfig;