-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.config.js
46 lines (44 loc) · 1.44 KB
/
jest.config.js
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
// Configuration for the jest unit test execution.
const config = {
verbose: true,
// Test against everything but e2e tests.
testPathIgnorePatterns: ['<rootDir>/e2e/', '<rootDir>/node_modules/'],
// Collect code coverage statistics by default.
collectCoverage: true,
coverageDirectory: 'coverage/js',
// Collect junit report information for test runs:
// https://www.npmjs.com/package/jest-junit
reporters: [
'default',
['jest-junit', { outputDirectory: 'reports/js', addFileAttribute: 'true' }],
],
// Configure for web app testing:
// https://jestjs.io/docs/configuration#testenvironment-string
testEnvironment: 'jsdom',
transform: {
// Configure so use esbuild, matching Hugo, with extra configuration for
// Preact usage in the jsx files.
// https://www.npmjs.com/package/esbuild-jest
'^.+\\.[tj]sx?$': [
'esbuild-jest',
{
jsxFactory: 'h',
jsxFragment: 'Fragment',
sourcemap: true,
},
],
},
transformIgnorePatterns: [
// Resolve jest parsing issue:
// https://github.com/react-dnd/react-dnd/issues/3443#issuecomment-1121131998
'/node_modules/(?!preact)',
],
moduleNameMapper: {
// https://preactjs.com/guide/v10/getting-started#aliasing-in-jest
'^react$': 'preact/compat',
'^react-dom/test-utils$': 'preact/test-utils',
'^react-dom$': 'preact/compat',
'^react/jsx-runtime$': 'preact/jsx-runtime',
},
};
module.exports = config;