@@ -4,10 +4,27 @@ const jestPuppeteerConfig = require('./jest-puppeteer.config.js')
44const { headless = true } = jestPuppeteerConfig . launch
55
66/**
7+ * Jest project config defaults
8+ *
9+ * @type {ProjectConfig }
10+ */
11+ const config = {
12+ cacheDirectory : '<rootDir>/.cache/jest' ,
13+
14+ // Enable Babel transforms until Jest supports ESM and `import()`
15+ // See: https://jestjs.io/docs/ecmascript-modules
16+ transform : {
17+ '^.+\\.(js|mjs)$' : [ 'babel-jest' , { rootMode : 'upward' } ]
18+ }
19+ }
20+
21+ /**
22+ * Jest config
23+ *
724 * @type {Config }
825 */
926module . exports = {
10- collectCoverageFrom : [ 'packages/**/*.js ' ] ,
27+ collectCoverageFrom : [ 'packages/**/*.{js,mjs} ' ] ,
1128
1229 // Reduce CPU usage during project test runs
1330 maxWorkers : headless
@@ -16,17 +33,21 @@ module.exports = {
1633
1734 projects : [
1835 {
36+ ...config ,
1937 displayName : 'JSDom' ,
2038 testEnvironment : 'jsdom' ,
21- testMatch : [ '<rootDir>/tests/integration/jsdom/**/*.test.js ' ]
39+ testMatch : [ '<rootDir>/tests/integration/jsdom/**/*.test.{js,mjs} ' ]
2240 } ,
2341 {
42+ ...config ,
2443 displayName : 'Pupppeteer' ,
44+ testEnvironment : 'jest-environment-puppeteer' ,
45+ testMatch : [ '<rootDir>/tests/integration/puppeteer/**/*.test.{js,mjs}' ] ,
46+
47+ // Web server and browser required
2548 globalSetup : 'jest-environment-puppeteer/setup' ,
2649 globalTeardown :
27- '<rootDir>/tests/integration/puppeteer/environment/teardown.mjs' ,
28- testEnvironment : 'jest-environment-puppeteer' ,
29- testMatch : [ '<rootDir>/tests/integration/puppeteer/**/*.test.js' ]
50+ '<rootDir>/tests/integration/puppeteer/environment/teardown.mjs'
3051 }
3152 ] ,
3253
@@ -38,5 +59,5 @@ module.exports = {
3859}
3960
4061/**
41- * @import { Config } from 'jest'
62+ * @import { Config, ProjectConfig } from 'jest'
4263 */
0 commit comments