- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 6.6k
 
Description
🐛 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:
    ...
    testEnvironment: "jsdom",
    testEnvironmentOptions: {
        virtualConsole: new require('jsdom').VirtualConsole()
    }
    ...
Then run:
- jest
 
Expected behavior
The tests run as they should.
Actual behavior
The tests die with an error from JSDOM:
TypeError: options.virtualConsole must be a VirtualConsole (from createVirtualConsole)
(createVirtualConsole is a bug in JSDOM - it should say VirtualConsole 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:
- jest --runInBand
 
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:
  System:
    OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz
  Binaries:
    Node: 12.0.0 - ~/.nvm/versions/node/v12.0.0/bin/node
    Yarn: 1.15.2 - ~/.nvm/versions/node/v12.0.0/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v12.0.0/bin/npm
  npmPackages:
    jest: 24 => 24.7.1 This is relate to #5223.