Skip to content

Commit

Permalink
Create Jest project for Turbopack (#73769)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Dec 17, 2024
1 parent 839c118 commit e72dc52
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contributing/core/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ To run the test suite using Turbopack, you can use the `TURBOPACK=1` environment
TURBOPACK=1 pnpm test-dev test/e2e/app-dir/app/
```

If you want to run a test again both Turbopack and Webpack, use Jest's `--projects` flag:

```sh
pnpm test-dev test/e2e/app-dir/app/ --projects jest.config.*
```

## Integration testing outside the repository with local builds

You can locally generate tarballs for each package in this repository with:
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const createJestConfig = nextJest()
// Any custom config you want to pass to Jest
/** @type {import('jest').Config} */
const customJestConfig = {
displayName: 'default',
testMatch: ['**/*.test.js', '**/*.test.ts', '**/*.test.jsx', '**/*.test.tsx'],
setupFilesAfterEnv: ['<rootDir>/jest-setup-after-env.ts'],
verbose: true,
Expand Down
16 changes: 16 additions & 0 deletions jest.config.turbopack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const createJestDefaultConfig = require('./jest.config.js')

module.exports = async function createConfig() {
const jestDefaultConfig = await createJestDefaultConfig()
/** @type {import('jest').Config} */
const customConfig = {
...jestDefaultConfig,
displayName: 'Turbopack',
setupFiles: [
...(jestDefaultConfig.setupFiles ?? []),
'<rootDir>/jest-setup-files.turbopack.js',
],
}

return customConfig
}
1 change: 1 addition & 0 deletions test/jest-setup-files.turbopack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
process.env.TURBOPACK = '1'

0 comments on commit e72dc52

Please sign in to comment.