-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
next/jest
sets NODE_ENV
to 'production'
#33005
Comments
As a workaround, users could create a util like this: export const isTestEnv = () => !!process.env.JEST_WORKER_ID; |
Having this same problem here. Another thing that I've noticed is that |
Hi, this has been updated in Note: you may need to run |
Thanks @ijjk! |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Run
next info
(available from version 12.0.8 and up)What version of Next.js are you using?
12.0.8-canary.17
What version of Node.js are you using?
14.17.6
What browser are you using?
N/A
What operating system are you using?
macOS 12.0.1 (21A559)
How are you deploying your application?
N/A
Describe the Bug
The
next/jest
preset setsNODE_ENV
to'production'
.Users familiar with Jest will expect
NODE_ENV
to be'test'
when running tests. The documentation says:In this case,
NODE_ENV
is indeed set to'test'
initially, but is replaced with'production'
. I've verified this simply by console logging the environment in the test setup files, and again in a test. I did take a quick look, but wasn't able to identify the cause.This is related to #17032 and #17903.
Expected Behavior
When running tests in Jest,
NODE_ENV
should be'test'
.To Reproduce
Create a new app using the Jest example:
Add the following line to the example test:
Run:
npm test
The text was updated successfully, but these errors were encountered: