Repository URL to install this package:
|
Version:
4.0.1 ▾
|
@doodle/frontend-config
/
jest.js
|
|---|
/**
* This is the default Jest configuration for Doodle frontends.
* Note: changes to this file affect all projects that depend on it.
*
* How to use:
* Create a jest.config.js file in your project and extend this configuration as
* shown in the following example.
* You can either extend the generated object, or pass the parameters specified
* in the docs of `generateJestConfig`.
*
* @example
* // File: web-my-frontend/jest.config.js
* const { generateJestConfig } = require('@doodle/frontend-config/jest');
* module.exports = generateJestConfig();
*/
const path = require('path');
module.exports = {
/**
* Generates the Jest configuration.
* @param {string[]} setupFiles Array of paths to js files used to setup the Jest test environment
* @param {object} moduleNameMapper sync with (or override) the moduleNameMapper defaults
*/
generateJestConfig: ({ setupFiles = [], moduleNameMapper = {} } = {}) => ({
moduleDirectories: ['node_modules', 'src'],
setupFilesAfterEnv: [path.resolve(__dirname, 'jest/test.setup.js'), ...setupFiles],
transformIgnorePatterns: ['/node_modules/(?!(@doodle)).+\\.js$'],
moduleNameMapper: {
'\\.(css|svg)$': path.resolve(__dirname, 'jest/fileMock.js'),
...moduleNameMapper,
},
snapshotSerializers: ['enzyme-to-json/serializer'],
collectCoverage: true,
collectCoverageFrom: ['src/**/*.js', '!**/node_modules/**'],
coverageDirectory: 'coverage',
reporters: [
'default',
[
'jest-junit',
{
output: 'coverage/junit.xml',
usePathForSuiteName: 'true',
},
],
],
}),
};