-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
79 lines (74 loc) · 2.27 KB
/
jest.config.js
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
/* global process */
import dotenv from 'dotenv'
import fs from 'fs'
if (fs.existsSync('./.env')) {
dotenv.config()
}
const { JEST_MEMORY } = process.env
const config = {
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(test).[jt]s?(x)'],
testEnvironment: 'jest-fixed-jsdom',
testEnvironmentOptions: {
url: 'http://localhost',
jsdom: {
url: 'http://localhost',
},
// https://stackoverflow.com/a/77415620/1734789
customExportConditions: [''],
},
roots: ['src'],
verbose: true,
setupFilesAfterEnv: ['<rootDir>/tests/setupTests.js'],
moduleNameMapper: {
'\\.(gif|ttf|eot|svg)$': '<rootDir>/tests/fileMock.js',
'^.+\\.(css|scss|less)$': '<rootDir>/tests/styleMock.js',
'^@/(.*)$': '<rootDir>/src/$1',
},
globals: {
NODE_ENV: 'test',
},
/**
* > We recommend placing the extensions most commonly used in your project
* > on the left, so if you are using TypeScript, you may want to consider
* > moving "ts" and/or "tsx" to the beginning of the array.
*
* ref: https://jestjs.io/docs/configuration#modulefileextensions-arraystring
*
* I checked the number of files in src, using `find src -name "*.js" | wc -l`
* and found that this is the order of most common file extensions:
*/
moduleFileExtensions: ['ts', 'js', 'jsx', 'tsx', 'json'],
// moduleDirectories: ['node_modules', 'src'],
testPathIgnorePatterns: ['src/fixtures', 'src/icons/untitled-ui'],
coverageReporters: ['text', 'clover', 'html'],
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}',
'!src/icons/untitled-ui/**/*',
'!src/test-utils/**/*',
'!src/fixtures/**/*',
'!src/**/*.d.ts',
'!src/**/*.stories.tsx',
'!src/**/*.{test,spec}.{js,jsx,ts,tsx}',
],
// this timeout does not cover RTLs waitFor and find methods. See setupTests for that.
testTimeout: 15 * 1000, // m
workerIdleMemoryLimit: JEST_MEMORY || '1500M',
transform: {
'^.+\\.(css|scss|sass|less)$': 'jest-preview/transforms/css',
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)':
'jest-preview/transforms/file',
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
},
}
export default config