Reputation: 32247
Technology Used:
If I run my tests one by one they individually pass
$ npm test test/file.to.test.js
...
Test Suites: 1 passed, 1 total
Tests: 6 passed, 6 total
However if I run my tests as a group then then errors are rampant
$ npm test
...
Test Suites: 6 failed, 6 total
Tests: 88 failed, 17 todo, 4 passed, 109 total
Question
My situation seems to be related to some kind of jest/puppeteer caching or chrome session sharing. Regargless, how can I debug this further?
Extra
While writing this question I found that using the argument --runInBand
(from this answer) makes it so all tests pass but they are run sequentially which makes the tests take substantially longer - normally jest tests run in parallel.
Settings
package.json
"test": "set NODE_ENV=test && jest --runInBand --detectOpenHandles --forceExit",
jest-puppeteer.config.js
module.exports = {
launch: {
devtools: true, // allows for use of 'debugger;' in tests
// executablePath: '/usr/bin/chromium-browser',
headless: true,
defaultViewport: {
width: 1024,
height: 768,
//isMobile: true,
//hasTouch: true,
},
ignoreDefaultArgs: ['--disable-extensions'],
args: [
'--enable-font-antialiasing',
'--font-render-hinting=medium',
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-setuid-sandbox',
'--no-first-run',
'--no-sandbox',
'--no-zygote',
'--single-process',
"--renderer",
"--no-service-autorun",
"--no-experiments",
"--no-default-browser-check",
"--disable-extensions",
]
},
// server: {
// command: "npm run serve",
// port: 9000,
// launchTimeout: 180000
// },
browser: 'chromium',
browserContext: 'default'
};
Upvotes: 1
Views: 2322
Reputation: 32247
I read quite a bit about this and while I'm not exactly sure why this happens there are a couple of pretty seamless work arounds
--runInBand OR --maxConcurrency=2
Upvotes: 1