-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-runner-jest.config.js
34 lines (29 loc) · 1.17 KB
/
test-runner-jest.config.js
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
const { getJestConfig } = require('@storybook/test-runner');
const defaultConfig = getJestConfig();
let headless = true;
process.argv.forEach(function (val, index, array) {
if (val === '--no-headless') {
headless = false;
}
});
const config = {
...defaultConfig,
testTimeout: 15 * 1000,
setupFilesAfterEnv: [...defaultConfig.setupFilesAfterEnv, '<rootDir>/test-runner-jest-setup.js'],
testEnvironmentOptions: {
'jest-playwright': {
...defaultConfig['jest-playwright'],
launchOptions: {
headless: headless,
},
},
},
};
// Since the command `test:e2e:storybook:command` is nested multiple times starting with `test:e2e` it's impossible
// to pass the `--max-workers` parameter from the CI/CD pipeline. So hacking a bit by defining a custom environment variable
// since Jest has none (https://jestjs.io/docs/environment-variables)
// Note: it cannot be set to undefined directly into the config object because Jest would take it due to the object key existing, so using a separate condition
if (typeof process.env.JEST_MAX_WORKERS === 'string') {
config.maxWorkers = parseInt(process.env.JEST_MAX_WORKERS, 10);
}
module.exports = config;