Unverified Commit 2d481584 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Turbopack build: Fix NODE_ENV test (#79377)

## What?

This test was checking for an arbitrary value, it wasn't clear to me why
this particular value given it's not in the source code.

I've changed it to an application-level check instead of checking the
Next.js internals.
parent fb096877
export default () => 'hi'
export default function Page() {
if (process.env.NODE_ENV === 'production') {
return <h1>Hello Production</h1>
} else {
return <h1>Hello Other</h1>
}
}
......@@ -94,15 +94,24 @@ describe('Non-Standard NODE_ENV', () => {
})
expect(staticFiles.length).toBeGreaterThan(0)
let foundProductionValue = false
let foundOtherValue = false
for (const file of staticFiles) {
const content = await fs.readFile(
join(appDir, '.next/static', file),
'utf8'
)
if (content.match(/cannot find module(?! for page)/i)) {
throw new Error(`${file} contains module not found error`)
if (content.includes('Hello Production')) {
foundProductionValue = true
}
if (content.includes('Hello Other')) {
foundOtherValue = true
}
}
expect(foundProductionValue).toBeTrue()
expect(foundOtherValue).toBeFalse()
})
it('should show the warning with NODE_ENV set to development with next build', async () => {
......
......@@ -16649,11 +16649,10 @@
"Non-Standard NODE_ENV should not show the warning with no NODE_ENV set",
"Non-Standard NODE_ENV should show the warning with NODE_ENV set to invalid value",
"Non-Standard NODE_ENV should show the warning with NODE_ENV set to invalid value (custom server)",
"Non-Standard NODE_ENV should show the warning with NODE_ENV set to production with next dev"
],
"failed": [
"Non-Standard NODE_ENV should show the warning with NODE_ENV set to production with next dev",
"Non-Standard NODE_ENV production mode should still DCE NODE_ENV specific code"
],
"failed": [],
"pending": [],
"flakey": [],
"runtimeError": false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment