-
-
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
Running tests with jest seems to trigger a change in environment variables #5322
Comments
It works correctly on mac, can you describe how it fails for you? As far as I know we only set a single environment variable, are any missing? |
I've seen that one come through indeed. It certainly won't show up on a Mac as it's a Windows specific environment variable (and execution path). The method called in chrome-finder.ts is here https://github.com/GoogleChrome/chrome-launcher/blob/master/src/chrome-finder.ts#L164. The error happens on the line https://github.com/GoogleChrome/chrome-launcher/blob/master/src/chrome-finder.ts#L171 where, for some reason the environment variables suddenly appear to be case sensitive when running through Jest. For example, On Windows, these are case-insensitive, and node respects this. See, for example, https://github.com/nodejs/node/blob/master/test/parallel/test-process-env.js#L93 I have no clue where to dig to find out why this changes while running in Jest. I've just verified (and pushed a fresh commit) that showcases this explicitly. The code run is:
On my environment bar
bar While console.log random.test.js:5
bar
console.log random.test.js:6
undefined |
Small addition, taken a look through the Jest code and noticed two I confirmed that using an assigned env like this showcases the same behavior as above running |
My guess is that we mess up when creating a process object to copy into the test process, see https://github.com/facebook/jest/blob/7743c0970e974bca166bff67099d28462ddb3187/packages/jest-util/src/create_process_object.js. See #4904. Do you think you could look into a fix? /cc @mjesun |
Hah, interesting! I was not aware of this behavior. It looks like The reason why this worked before is because the I will investigate what can we do here; but I guess a I'm trying to get some clarification about how Node bootstraps the main context, and see if we can bootstrap any random context created via |
Thanks a lot @mjesun ! |
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. |
Cross post for GoogleChrome/chrome-launcher#86
I've created a reproduction here: https://github.com/janpieterz/find-chrome-issue
npm start
works,npm test
fails.I launch a Chromeless instance and do something there, this uses chrome-launcher internally to launch a chrome instance. This relies on certain environment variables to detect the Program files folders. These should be case insensitive on Windows + Node, but somehow running it with Jest seems to make them case sensitive.
This is present on:
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.16299 N/A Build 16299
The text was updated successfully, but these errors were encountered: