Repository navigation
Expand file tree
/
Copy pathjest.config.js
More file actions
62 lines (59 loc) · 2.38 KB
/
Copy pathjest.config.js
File metadata and controls
62 lines (59 loc) · 2.38 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
const nextJest = require('next/jest')
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files
dir: './',
})
// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testEnvironment: 'jest-environment-jsdom',
collectCoverageFrom: [
'components/**/*.{js,jsx,ts,tsx}',
'hooks/**/*.{js,jsx,ts,tsx}',
'utils/**/*.{js,jsx,ts,tsx}',
'stores/**/*.{js,jsx,ts,tsx}',
'lib/**/*.{js,jsx,ts,tsx}',
'app/**/*.{js,jsx,ts,tsx}',
'!app/layout.tsx',
'!app/**/layout.tsx',
'!app/**/loading.tsx',
'!app/**/error.tsx',
'!app/**/not-found.tsx',
'!app/api/**',
'!**/*.d.ts',
'!**/node_modules/**',
],
testMatch: ['**/__tests__/**/*.(ts|tsx|js)', '**/*.(test|spec).(ts|tsx|js)'],
// e2e/ holds the Playwright suite (npm run test:e2e)
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/e2e/'],
moduleNameMapper: {
// @react-email/render loads react-dom/server with a dynamic import, which
// Jest refuses; the shim renders with react-dom/server's static import.
'^@react-email/render$': '<rootDir>/jest.react-email-render.js',
// next/image's loader (next.config.js images.loaderFile): the build aliases
// Next's default loader to it, so the tests do the same.
'^next/dist/shared/lib/image-loader$': '<rootDir>/lib/imageLoader.ts',
// Handle module aliases (if you use them in your Next.js app)
'^@/components/(.*)$': '<rootDir>/components/$1',
'^@/app/(.*)$': '<rootDir>/app/$1',
'^@/utils/(.*)$': '<rootDir>/utils/$1',
'^@/hooks/(.*)$': '<rootDir>/hooks/$1',
'^@/stores/(.*)$': '<rootDir>/stores/$1',
'^@/lib/(.*)$': '<rootDir>/lib/$1',
'^@/db$': '<rootDir>/db',
'^@/db/(.*)$': '<rootDir>/db/$1',
'^@/types/(.*)$': '<rootDir>/types/$1',
'^@/auth$': '<rootDir>/auth',
'^@/typings$': '<rootDir>/typings',
},
coverageThreshold: {
global: {
branches: 70,
functions: 70,
lines: 70,
statements: 70,
},
},
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)