Skip to content

Commit e72dc52

Browse files
authored
Create Jest project for Turbopack (#73769)
1 parent 839c118 commit e72dc52

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

contributing/core/testing.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ To run the test suite using Turbopack, you can use the `TURBOPACK=1` environment
115115
TURBOPACK=1 pnpm test-dev test/e2e/app-dir/app/
116116
```
117117

118+
If you want to run a test again both Turbopack and Webpack, use Jest's `--projects` flag:
119+
120+
```sh
121+
pnpm test-dev test/e2e/app-dir/app/ --projects jest.config.*
122+
```
123+
118124
## Integration testing outside the repository with local builds
119125

120126
You can locally generate tarballs for each package in this repository with:

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const createJestConfig = nextJest()
55
// Any custom config you want to pass to Jest
66
/** @type {import('jest').Config} */
77
const customJestConfig = {
8+
displayName: 'default',
89
testMatch: ['**/*.test.js', '**/*.test.ts', '**/*.test.jsx', '**/*.test.tsx'],
910
setupFilesAfterEnv: ['<rootDir>/jest-setup-after-env.ts'],
1011
verbose: true,

jest.config.turbopack.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const createJestDefaultConfig = require('./jest.config.js')
2+
3+
module.exports = async function createConfig() {
4+
const jestDefaultConfig = await createJestDefaultConfig()
5+
/** @type {import('jest').Config} */
6+
const customConfig = {
7+
...jestDefaultConfig,
8+
displayName: 'Turbopack',
9+
setupFiles: [
10+
...(jestDefaultConfig.setupFiles ?? []),
11+
'<rootDir>/jest-setup-files.turbopack.js',
12+
],
13+
}
14+
15+
return customConfig
16+
}

test/jest-setup-files.turbopack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
process.env.TURBOPACK = '1'

0 commit comments

Comments
 (0)