Files
doormilxpress_astryx/jest.config.cjs
2026-08-27 13:40:48 +05:30

41 lines
1.3 KiB
JavaScript

/**
* Jest for the Doormile console.
*
* Babel is configured INLINE rather than through a babel.config file at the
* repo root on purpose: @vitejs/plugin-react picks up root Babel config, so a
* babel.config.cjs added for tests would silently change how production
* bundles are compiled. Test tooling must not be able to move the build.
*/
const babelOptions = {
babelrc: false,
configFile: false,
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
['@babel/preset-react', { runtime: 'automatic' }],
],
plugins: [require.resolve('./tests/setup/babel-plugin-import-meta.cjs')],
};
module.exports = {
testEnvironment: 'jsdom',
roots: ['<rootDir>/tests'],
testMatch: ['**/*.test.js', '**/*.test.jsx'],
setupFilesAfterEnv: ['<rootDir>/tests/setup/jest.setup.cjs'],
clearMocks: true,
restoreMocks: true,
transform: {
'^.+\.[jt]sx?$': ['babel-jest', babelOptions],
},
moduleNameMapper: {
'\.(css|less|scss|sass)$': '<rootDir>/tests/setup/styleMock.cjs',
'\.(png|jpe?g|gif|svg|webp|woff2?|ttf|eot)$': '<rootDir>/tests/setup/fileMock.cjs',
'^@/(.*)$': '<rootDir>/src/$1',
},
collectCoverageFrom: [
'src/api/doormile/**/*.js',
'src/lib/**/*.js',
'src/utils/**/*.js',
'!src/**/*.md',
],
};