-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathjest.config.js
More file actions
125 lines (121 loc) · 5.58 KB
/
jest.config.js
File metadata and controls
125 lines (121 loc) · 5.58 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* 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,
//NOTE: we manually re-enable tests here until we finish migrating to Chakra v3
testMatch: [
createTestGlob('components/display-price'),
createTestGlob('components/fade'),
createTestGlob('components/footer'),
createTestGlob('components/hero'),
createTestGlob('components/icons'),
createTestGlob('components/image-gallery'),
createTestGlob('components/drawer-menu'),
createTestGlob('components/header'),
createTestGlob('components/links-list'),
createTestGlob('components/locale-selector'),
createTestGlob('components/nested-accordion'),
createTestGlob('components/pagination'),
createTestGlob('components/product-scroller'),
createTestGlob('components/product-tile'),
createTestGlob('components/product-view'),
createTestGlob('components/promo-popover'),
createTestGlob('components/quantity-picker'),
createTestGlob('components/search'),
createTestGlob('components/social-icons'),
createTestGlob('components/swatch-group'),
createTestGlob('components/toaster'),
createTestGlob('components/list-menu'),
createTestGlob('components/skip-nav'),
createTestGlob('components/login'),
createTestGlob('components/register'),
createTestGlob('components/email-confirmation'),
createTestGlob('components/field'),
createTestGlob('components/reset-password'),
createTestGlob('components/with-registration'),
createTestGlob('components/social-login'),
createTestGlob('components/toggle-card'),
createTestGlob('pages/home'),
createTestGlob('pages/cart'),
createTestGlob('pages/product-list'),
createTestGlob('components/offline-banner'),
createTestGlob('components/offline-boundary'),
// createTestGlob('pages/login'), // TODO: enable after Account page has been migrated
createTestGlob('pages/login-redirect'),
createTestGlob('pages/social-login-redirect'),
// createTestGlob('pages/registration'), // TODO: enable after Account page has been migrated
'<rootDir>/src/pages/checkout/partials/contact-info.test.js',
'<rootDir>/src/pages/checkout/partials/login-state.test.js',
'<rootDir>/src/utils/responsive-image.test.js',
'<rootDir>/src/hooks/use-toast.test.js',
'<rootDir>/src/pages/product-detail/metadata.test.js',
'<rootDir>/src/pages/product-list/metadata.test.js',
'<rootDir>/src/hooks/use-toast.test.js'
// '<rootDir>/src/hooks/use-auth-modal.test.js' // TODO: enable after Account page has been migrated
],
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} : {})
}