forked from alphagov/govuk-design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.mjs
40 lines (31 loc) · 1.07 KB
/
jest.config.mjs
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
import jestPuppeteerConfig from './jest-puppeteer.config.js'
// Detect when browser has been launched headless
const { headless } = jestPuppeteerConfig.launch
/**
* Jest config
*
* @type {import('@jest/types').Config.InitialOptions}
*/
export default {
preset: 'jest-puppeteer',
// Reduce CPU usage during project test runs
maxWorkers: headless
? '50%' // Matches Jest default (50%) via `--watch`
: 1, // Use only 1x browser window when headless
// Custom matchers
setupFilesAfterEnv: ['./config/jest/matchers.js'],
// Environment defaults for JSDOM
testEnvironmentOptions: {
url: 'https://design-system.service.gov.uk'
},
// Enable GitHub Actions reporter UI
reporters: ['default', 'github-actions'],
// Test timeout increased (5s to 15s)
testTimeout: 15000,
// Enable Babel transforms until Jest supports ESM
// See: https://jestjs.io/docs/ecmascript-modules
testMatch: ['**/*.test.{js,mjs}'],
transform: { '^.+\\.m?js$': ['babel-jest'] },
// Ignore built fixtures during `--watch`
watchPathIgnorePatterns: ['fixtures/build']
}