This is a minimum reproduction of an issue with passing functions to a custom testEnvironment as options while Jest is running tests in parallel.
To reproduce the bug:
- clone
yarn install
yarn jest --runInBand
-> all tests passyarn jest --watch
-> all tests fail