-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Closed
Description
Run next info (available from version 12.0.8 and up)
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101
Binaries:
Node: 14.17.6
npm: 8.1.4
Yarn: 1.22.15
pnpm: N/A
Relevant packages:
next: 12.0.8-canary.17
react: 17.0.2
react-dom: 17.0.2
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 sets NODE_ENV to 'production'.
Users familiar with Jest will expect NODE_ENV to be 'test' when running tests. The documentation says:
Set to
'test'if it's not already set to something else.
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:
npx create-next-app --example with-jest with-jest-appAdd the following line to the example test:
// __tests__/index.test.tsx
console.log(process.env.NODE_ENV); // productionRun:
npm testfranciscobonand
Metadata
Metadata
Assignees
Labels
No labels