-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathjest.config.ts
79 lines (71 loc) · 2.06 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
72
73
74
75
76
77
78
79
import * as dotenv from 'dotenv'
dotenv.config({ path: '../..' })
// Next config does not work with es modules
// nextJest()()().then((config) => console.log('NEXT CONFIG', config, config.transform))
/**
* If you have a babel error in jest test environment
* add the faulty package to this list
*/
const transformIgnorePackages = [
'uuid',
'nanoid',
'undici',
'node-fetch',
'data-uri-to-buffer',
'fetch-blob',
'formdata-polyfill',
'@aws-sdk/middleware-retry',
'@aws-sdk/client-s3',
'axios',
]
const packagesNamesPattern = transformIgnorePackages.join('|')
const nodeModulesTransformIgnorePattern = `node_modules/(?!${packagesNamesPattern})`
const config = {
moduleFileExtensions: ['js', 'ts', 'tsx'],
transformIgnorePatterns: [
nodeModulesTransformIgnorePattern,
'^.+\\.module\\.(css|sass|scss)$',
],
setupFilesAfterEnv: ['<rootDir>/jest/jest.setup.ts'],
testMatch: [
'**/*.spec.ts',
'**/*.spec.tsx',
'**/*.integration.ts',
'**/*.integration.tsx',
],
moduleNameMapper: {
'^.+\\.module\\.(css|sass|scss)$':
'<rootDir>/node_modules/next/dist/build/jest/object-proxy.js',
'^.+\\.(css|sass|scss)$':
'<rootDir>/node_modules/next/dist/build/jest/__mocks__/styleMock.js',
'^.+\\.(png|jpg|jpeg|gif|webp|avif|ico|bmp)$':
'<rootDir>/node_modules/next/dist/build/jest/__mocks__/fileMock.js',
'^.+\\.(svg)$':
'<rootDir>/node_modules/next/dist/build/jest/__mocks__/fileMock.js',
'^@pt/(.*)$': '<rootDir>/src/$1',
},
testPathIgnorePatterns: ['/node_modules/', '/.next/'],
watchPathIgnorePatterns: ['/.next/'],
globals: {
'ts-jest': {
tsconfig: {
jsx: 'react',
},
},
},
testEnvironment: 'node',
transform: {
'^.+\\.(js|jsx|ts|tsx|mjs)$': [
'<rootDir>/apps/web/node_modules/next/dist/build/swc/jest-transformer.js',
{
nextConfig: undefined,
jsConfig: undefined,
resolvedBaseUrl: undefined,
hasServerComponents: undefined,
isEsmProject: false,
pagesDir: undefined,
},
],
},
}
export default config