-
Notifications
You must be signed in to change notification settings - Fork 5
/
jest.config.ts
71 lines (67 loc) · 2.18 KB
/
jest.config.ts
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
66
67
68
69
70
71
import type { Config } from 'jest'
import nextJest from 'next/jest.js'
import path from 'path'
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})
// Add any custom config to be passed to Jest
const customJestConfig: Config = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleDirectories: [
'node_modules',
'<rootDir>/',
path.join(__dirname, 'test'),
],
moduleNameMapper: {
'^@/__tests__/(.*)$': '<rootDir>/src/__tests__/$1',
'^@/data/(.*)$': '<rootDir>/src/data/$1',
'^@/hooks/(.*)$': '<rootDir>/src/hooks/$1',
'^@/lib/(.*)$': '<rootDir>/src/lib/$1',
'^@/mocks/(.*)$': '<rootDir>/src/mocks/$1',
'^@/pages/(.*)$': '<rootDir>/src/pages/$1',
'^@/templates/(.*)$': '<rootDir>/src/templates/$1',
'^@/types/(.*)$': '<rootDir>/src/types/$1',
'^axios$': require.resolve('axios'),
},
testEnvironment: 'jest-environment-jsdom',
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}',
'!**/__tests__/**.test.{js,jsx,ts,tsx}',
'!example_tests/**/*.{js,jsx,ts,tsx}',
'!.storybook/*.{js,jsx,ts,tsx}',
'!playwright/**/*.{js,jsx,ts,tsx}',
'!src/**/*.stories.{js,jsx,ts,tsx}',
'!src/stories/**',
// Some files excluded from unit test coverage reporting in favor of e2e tests
'!src/lib/utils/redisCache.ts',
'!src/lib/drupal/drupalClient.ts',
'!src/lib/drupal/staticProps.ts',
'!src/lib/drupal/staticPaths.ts',
'!src/lib/drupal/query.ts',
'!src/templates/common/meta/index.tsx',
'!src/pages/**',
'!src/types/**/*.{js,jsx,ts,tsx}',
],
coverageThreshold: {
global: {
statements: 80,
branches: 80,
functions: 80,
lines: 80,
},
},
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
testPathIgnorePatterns: [
'/node_modules/',
'<rootDir>/example_tests',
'<rootDir>/playwright',
'<rootDir>/scripts',
],
transformIgnorePatterns: ['/dist/.+\\.js'],
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default createJestConfig(customJestConfig)