The previous approach did avoid a fair number of jest.mock calls, but made debugging the tests harder. If you don't know about the mapping it's unclear why the imported module does not behave as normal. By forcing the use of jest.mock it means that the answer to that question is in the test you are working on.
22 lines
785 B
JavaScript
22 lines
785 B
JavaScript
module.exports = {
|
|
moduleNameMapper: {
|
|
'\\.(jpg|jpeg|png|svg|woff|woff2)$': '<rootDir>/src/__mocks__/fileMock.js',
|
|
// Plain CSS - match css files that don't end with
|
|
// '.module.css' https://regex101.com/r/VzwrKH/4
|
|
'^(?!.*\\.module\\.css$).*\\.css$': '<rootDir>/src/__mocks__/styleMock.js',
|
|
// CSS Modules - match files that end with 'module.css'
|
|
'\\.module\\.css$': 'identity-obj-proxy',
|
|
'react-i18next': '<rootDir>/src/__mocks__/react-i18nextMock.js'
|
|
},
|
|
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/.cache/'],
|
|
globals: {
|
|
__PATH_PREFIX__: ''
|
|
},
|
|
verbose: true,
|
|
transform: {
|
|
'^.+\\.js$': '<rootDir>/jest.transform.js'
|
|
},
|
|
transformIgnorePatterns: ['node_modules/(?!(gatsby)/)'],
|
|
setupFilesAfterEnv: ['./jest.setup.js']
|
|
};
|