-
Notifications
You must be signed in to change notification settings - Fork 223
/
jest.config.cjs
49 lines (48 loc) · 1.83 KB
/
jest.config.cjs
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
// https://github.com/ai/nanoid/issues/363#issuecomment-1140906651
const esModulesToIgnore = ['nanoid', 'lodash-es', 'sinon'].join('|')
module.exports = {
collectCoverage: true,
collectCoverageFrom: [
'serverless/src/**/*.js',
'static/src/**/*.{js,jsx}',
'sharedUtils/**/*.js'
],
moduleNameMapper: {
// Use the moduleNameMapper for all images except the logo.png that exist in the portals directory
'(?<!/portals)(?<!/logo).(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/static/src/js/util/mocks/fileMock.js',
'^.+\\.(css|less|scss)$': 'babel-jest',
// Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports. See https://github.com/uuidjs/uuid/issues/451
uuid: require.resolve('uuid'),
'^nanoid(/(.*)|$)': 'nanoid$1',
'react-leaflet': '<rootDir>/static/src/js/util/mocks/reactLeafletMock.js',
// After the update to 1.x the CJS changed import method. Adding a module mapper to resolve issues. See https://stackoverflow.com/a/74079349
'^axios$': require.resolve('axios')
},
coveragePathIgnorePatterns: [
'package.json',
'package-lock.json'
],
setupFilesAfterEnv: [
'<rootDir>/test-env.js'
],
// Skips files from running tests
testPathIgnorePatterns: [
'mocks.js',
'node_modules',
'/tests'
],
// Skips modules from being visible to jest
modulePathIgnorePatterns: [
'/tests/e2e',
'package.json',
'package-lock.json'
],
transform: {
// Use the fileTransformer for all the logo.pngs that exist in the portals directory
'(?<=/portals)(?<=/logo).png':
'<rootDir>/static/src/js/util/jest/fileTransformer.cjs',
'^.+\\.(js|jsx)$': 'babel-jest'
},
testEnvironment: 'jsdom',
transformIgnorePatterns: [`/node_modules/(?!${esModulesToIgnore})`]
}