-
Notifications
You must be signed in to change notification settings - Fork 82
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
Ensure run with NODE_ENV set to test #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need branch the code depending if we run in debug
mode or not? Instead of traying to match the same environment in both cases can't we use the same code path?
@@ -64,6 +64,10 @@ async function testRunner(argv) { | |||
|
|||
shell.runCommand(command, commandArgs); | |||
} else { | |||
// Jest will not set the env if not run from the bin executable | |||
if (process.env.NODE_ENV == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an environment variable is not set its value is always undefined
and not null
.
if (process.env.NODE_ENV == null) { | |
if (process.env.NODE_ENV === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the exact code Jest uses. I want to keep parity between the two modes. It's very confusing to get a failure in a test and then try to debug and get different results.
@pmdartus Yeah, in non-debug mode we can run Jest via the same I remember @micmmakarov did it this way for testability, but I'm sure we can find a way to have parity between commands and also make it testable. Any concerns Mikhail? |
@trevor-bliss LGTM |
To mimic the environment when the
jest
executable is invoked directly, setprocess.env.NODE_ENV
to 'test' if not already set.