-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSDOM virtualConsole environment option defunct in parallel mode #8393
JSDOM virtualConsole environment option defunct in parallel mode #8393
Comments
In the test processing the environment when setup/teardown in each test suites and const { VirtualConsole } = require('jsdom')
module.exports = {
testEnvironment: 'jsdom',
testEnvironmentOptions: {
virtualConsole: VirtualConsole,
},
}
// instead of
const { VirtualConsole } = require('jsdom')
module.exports = {
testEnvironment: 'jsdom',
testEnvironmentOptions: {
virtualConsole: new VirtualConsole(),
},
} If you want to use @SimenB @jeysal Should we add an option for |
I think this exposes a more serious issue with Jest: that the presence or absence of |
I'd guess the instance is lost when serialising config to the worker. You should create your own test environment instead so it's instantiated inside the worker. const JsdomEnv = require('jest-environment-jsdom');
module.exports = class MyEnv extends JsdomEnv {
constructor(config, context) {
super(
{
...config,
testEnvironmentOptions: { my: 'things' },
},
context,
);
}
}; This is written on mobile, so please excuse typos :) |
@SimenB - thanks for the suggestion. I wound up stubbing away |
The bug here is that it works in I'll close this as the solution to your issue is to create a custom environment or just stub out
See above - the solution in this case is a custom env - we currently do not support non-serializable things (like functions) in the config |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
Overriding virtual console for
jsdom
isn't possible for parallel execution.To Reproduce
(Repl.it link further down.)
In any project using jest with at least two test files using
jsdom
, override the virtual console setting:In jest.config.js:
Then run:
Expected behavior
The tests run as they should.
Actual behavior
The tests die with an error from JSDOM:
(
createVirtualConsole
is a bug in JSDOM - it should sayVirtualConsole
AFAIK.)This looks like a bug in the way Jest fans out test to workers, because if you runs sequentially, it works. To demonstrate this, try:
Link to repl or repo (highly encouraged)
https://repl.it/@mzedeler/Reproducing-virtualConsole-option-bug
Change first line in
index.js
to switch between passing and failing case.Issues without a reproduction link are likely to stall.
Run
npx envinfo --preset jest
Paste the results here:
This is relate to #5223.
The text was updated successfully, but these errors were encountered: