-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathjest.config.js
More file actions
73 lines (70 loc) · 2.93 KB
/
jest.config.js
File metadata and controls
73 lines (70 loc) · 2.93 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
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
const path = require('path')
const base = require('@salesforce/pwa-kit-dev/configs/jest/jest.config.js')
const createTestGlob = (relativePath) => {
return `<rootDir>/src/${relativePath}/**/*.test.{js,jsx,ts,tsx}`
}
module.exports = {
...base,
moduleNameMapper: {
...base.moduleNameMapper,
'^react$': '<rootDir>/node_modules/react/index.js',
'^react-router-dom(.*)$': '<rootDir>/node_modules/react-router-dom/index.js',
'^@tanstack/react-query$':
'<rootDir>/node_modules/@tanstack/react-query/build/modern/index.cjs',
'^is-what$': '<rootDir>/node_modules/is-what/dist/cjs/index.cjs',
'^copy-anything$': '<rootDir>/node_modules/copy-anything/dist/cjs/index.cjs',
'^@salesforce/cc-datacloud-typescript$':
'<rootDir>/node_modules/@salesforce/cc-datacloud-typescript/dist/index.js',
// Chakra v3 use ESM by default, but we need to use CJS for jest 27
'^@ark-ui/react/(.*)$': [
'<rootDir>/node_modules/@ark-ui/react/dist/components/$1/index.cjs',
'<rootDir>/node_modules/@ark-ui/react/dist/components/$1.cjs',
'<rootDir>/node_modules/@ark-ui/react/dist/providers/$1/index.cjs',
'<rootDir>/node_modules/@ark-ui/react/dist/providers/$1.cjs'
],
'^@chakra-ui/react/(.*)$': [
'<rootDir>/node_modules/@chakra-ui/react/dist/cjs/$1/index.cjs',
'<rootDir>/node_modules/@chakra-ui/react/dist/cjs/index.cjs'
],
'^proxy-compare$': '<rootDir>/node_modules/proxy-compare/dist/cjs/index.js',
'^uqr$': '<rootDir>/node_modules/uqr/dist/index.cjs',
// handle pwa-kit extensibility special import
'^overridable!(.*)': '$1'
},
setupFilesAfterEnv: [path.join(__dirname, 'jest-setup.js')],
collectCoverageFrom: [
'src/**/*.{js,jsx}',
'app/**/*.{js,jsx}',
'non-pwa/**/*.{js,jsx}',
'worker/**/*.{js,jsx}',
'scripts/generator/*.{js,jsx}',
'src/**/*.{js,jsx}',
'!app/pages/test-container/**/*.{js,jsx}',
'!app/utils/test-utils.js',
'!app/mocks/*.js',
'!app/main.jsx',
'!app/loader.js',
'!app/ssr.js',
'!app/static/**',
'!app/theme/**',
'!node_modules/**'
],
//@TODO: Revert this threshold back to original numbers stattements: 80, branches: 72, functions: 78, lines: 83
// TODO: Revert this threshold once we start adding tests back to the codebase
coverageThreshold: {
global: {
statements: 73,
branches: 60,
functions: 65,
lines: 74
}
},
// Increase to: 6 x default timeout of 5 seconds
...(process.env.CI ? {testTimeout: 30000} : {})
}