Skip to content

Commit

Permalink
chore: Add support for ESM in jest (#2606)
Browse files Browse the repository at this point in the history
  • Loading branch information
gethinwebster authored Aug 23, 2024
1 parent 04ca596 commit f30d9c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ npx jest -c jest.motion.config.js src/flashbar
npx jest -c jest.build-tools.config.js build-tools/stylelint
```

Note: when running jest directly you may see errors about `--experimental-vm-modules`, to fix this you can set this NodeJS flag as follows:

```
export NODE_OPTIONS="$NODE_OPTIONS --experimental-vm-modules"
```

### Run visual regression tests

Visual regression tests for the permutation pages are automatically run when opening a pull request in GitHub.
Expand Down
5 changes: 4 additions & 1 deletion build-tools/tasks/integ.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ module.exports = task('test:integ', async () => {
await waitOn({ resources: ['http://localhost:8080'] });

const files = glob.sync('src/**/__integ__/**/*.test.ts');
await execa('jest', ['-c', 'jest.integ.config.js', ...files], { stdio: 'inherit' });
await execa('jest', ['-c', 'jest.integ.config.js', ...files], {
stdio: 'inherit',
env: { ...process.env, NODE_OPTIONS: '--experimental-vm-modules' },
});

devServer.cancel();
});
5 changes: 4 additions & 1 deletion build-tools/tasks/motion.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ module.exports = task('test:motion', async () => {
await waitOn({ resources: ['http://localhost:8080'] });

const files = glob.sync('src/**/__motion__/**/*.test.ts');
await execa('jest', ['-c', 'jest.motion.config.js', ...files], { stdio: 'inherit' });
await execa('jest', ['-c', 'jest.motion.config.js', ...files], {
stdio: 'inherit',
env: { ...process.env, NODE_OPTIONS: '--experimental-vm-modules' },
});

devServer.cancel();
});

0 comments on commit f30d9c8

Please sign in to comment.