-
Notifications
You must be signed in to change notification settings - Fork 15
/
jest.config.js
71 lines (71 loc) · 3 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
module.exports = {
// Added `.mts` files since by default jest does not support them
moduleFileExtensions: [
'js',
'mjs',
'mts',
'cjs',
'jsx',
'ts',
'tsx',
'json',
'node',
],
// Changed to add mts files to `transform` option since the default regex value does not include them
transform: { '\\.m?[jt]sx?$': 'babel-jest' },
// Add crypto-es to transformIgnorePatterns as it is an ESM-only package
transformIgnorePatterns: ['/node_modules/(?!(crypto-es)/)'],
// The paths to modules that run some code to configure or set up the testing environment before each test
setupFiles: [
'./tests/setupReactTestingLibrary.mts',
'jest-localstorage-mock',
],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: ['./tests/setupAfterEnv.mts'],
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
snapshotSerializers: ['./tests/axiosErrorSerializer.mts'],
// The test environment that will be used for testing
testEnvironment: 'jsdom',
// The regexp pattern or array of patterns that Jest uses to detect test files
testRegex: ['.+\\.test.[jt]s(x?)$', '!dist'],
// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,
// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: ['**/src/**/*.{js,jsx,ts,tsx}', '!**/.vscode/**/*'],
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 90,
functions: 90,
lines: 90,
statements: 90,
},
},
// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: [
'/node_modules/',
'__tests__/',
'packages/react/src/analytics/integrations/Forter/loadForterScriptForSiteId.ts',
'packages/redux/src/entities/schemas',
'__fixtures__',
],
// A map from regular expressions to module names that allow to stub out resources with a single module
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.m?jsx?$': '$1', // This is to support the resolution algorithm in jest which does not use extensions
'^lodash-es$': 'lodash', // Map lodash-es to lodash so we do not need to transpile it
'^@farfetch/blackout-analytics(.*)$': '<rootDir>/packages/analytics/src$1',
'^@farfetch/blackout-client/src(.*)$': '<rootDir>/packages/client/src$1',
'^@farfetch/blackout-client(.*)$': '<rootDir>/packages/client/src$1',
'^@farfetch/blackout-redux/src(.*)$': '<rootDir>/packages/redux/src$1',
'^@farfetch/blackout-redux(.*)$': '<rootDir>/packages/redux/src$1',
'^jestSetup$': '<rootDir>/jestSetup',
'^tests(.*)\\.m?js$': '<rootDir>/tests$1',
},
// Add custom reporters to Jest
reporters: ['default'],
// Allows the usage of custom watch plugins
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
};