-
-
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
Node process.domain behavior broken when running code using Jest #7247
Comments
I doubt we'll spend time implementing support for domains in Jest seeing as it's deprecated. However, if the diff is minimal, a PR is of course welcome 🙂 The |
Thanks for pointing me to that code @SimenB - it actually made me think about a workaround to make the
module.exports = () => { require('domain') } and use it as the global-setup file in my module.exports = {
globalSetup: `test/setup/global-setup.js`
} Since |
Fixes jestjs#7247: Explicitly copy domain to new process
For anyone subscribed: should be fixed in #9136 which will come in Jest 25 |
Hi, @SimenB . Could you update |
ping @SimenB |
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
Jest seems to modify the
process
object in such a way that breaks the ability to run code inside a domain - i.e.,process.domain
does not change to be the current domain set by calling theenter()
method of a domain or running an arbitrary code through therun()
method.To Reproduce
Steps to reproduce the behavior:
Run jest with the following spec file (not setup or actual production-code required):
Expected behavior
The test above should pass, since
process.domain
should be set to the actual domain object in which the code is being run. See https://nodejs.org/docs/latest-v8.x/api/domain.html#domain_domain_enter.Running the test in
mocha
+chai
(with the relevant changes to the test only - requiringexpect
fromchai
and changing the matcher tonot.to.be.null
) results in a passing test.Link to repl or repo
https://repl.it/@HarelMoshe/testNodeDomains
Output from
npx envinfo --preset jest
:The text was updated successfully, but these errors were encountered: