Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a750d1cc
Unverified
Commit
a750d1cc
authored
Mar 28, 2019
by
Luis Fernando Alvarez D
Committed by
GitHub
Mar 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NODE_ENV is set to undefined before running a test command (#6823)
parent
2f325e0f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
21 deletions
+16
-21
index.test.js
test/integration/production-build-dir/test/index.test.js
+0
-1
index.test.js
test/integration/production-config/test/index.test.js
+10
-16
index.test.js
test/integration/production/test/index.test.js
+2
-3
next-test-utils.js
test/lib/next-test-utils.js
+4
-1
No files found.
test/integration/production-build-dir/test/index.test.js
View file @
a750d1cc
...
@@ -16,7 +16,6 @@ describe('Production Custom Build Directory', () => {
...
@@ -16,7 +16,6 @@ describe('Production Custom Build Directory', () => {
it
(
'should render the page'
,
async
()
=>
{
it
(
'should render the page'
,
async
()
=>
{
const
result
=
await
runNextCommand
([
'build'
,
'build'
],
{
const
result
=
await
runNextCommand
([
'build'
,
'build'
],
{
cwd
:
join
(
__dirname
,
'..'
),
cwd
:
join
(
__dirname
,
'..'
),
spawnOptions
:
{
env
:
{
...
process
.
env
,
NODE_ENV
:
'production'
}
},
stdout
:
true
,
stdout
:
true
,
stderr
:
true
stderr
:
true
})
})
...
...
test/integration/production-config/test/index.test.js
View file @
a750d1cc
...
@@ -41,27 +41,21 @@ describe('Production Config Usage', () => {
...
@@ -41,27 +41,21 @@ describe('Production Config Usage', () => {
describe
(
'env'
,
()
=>
{
describe
(
'env'
,
()
=>
{
it
(
'should fail with __ in env key'
,
async
()
=>
{
it
(
'should fail with __ in env key'
,
async
()
=>
{
const
result
=
await
runNextCommand
([
'build'
,
appDir
],
{
spawnOptions
:
{
const
result
=
await
runNextCommand
([
'build'
,
appDir
],
{
env
:
{
env
:
{
ENABLE_ENV_FAIL_UNDERSCORE
:
true
},
...
process
.
env
,
ENABLE_ENV_FAIL_UNDERSCORE
:
true
}
},
stdout
:
true
,
stdout
:
true
,
stderr
:
true
})
stderr
:
true
})
expect
(
result
.
stderr
).
toMatch
(
/The key "__NEXT_MY_VAR" under/
)
expect
(
result
.
stderr
).
toMatch
(
/The key "__NEXT_MY_VAR" under/
)
})
})
it
(
'should fail with NODE_ in env key'
,
async
()
=>
{
it
(
'should fail with NODE_ in env key'
,
async
()
=>
{
const
result
=
await
runNextCommand
([
'build'
,
appDir
],
{
spawnOptions
:
{
const
result
=
await
runNextCommand
([
'build'
,
appDir
],
{
env
:
{
env
:
{
ENABLE_ENV_FAIL_NODE
:
true
},
...
process
.
env
,
ENABLE_ENV_FAIL_NODE
:
true
}
},
stdout
:
true
,
stdout
:
true
,
stderr
:
true
})
stderr
:
true
})
expect
(
result
.
stderr
).
toMatch
(
/The key "NODE_ENV" under/
)
expect
(
result
.
stderr
).
toMatch
(
/The key "NODE_ENV" under/
)
})
})
...
...
test/integration/production/test/index.test.js
View file @
a750d1cc
...
@@ -27,9 +27,8 @@ const context = {}
...
@@ -27,9 +27,8 @@ const context = {}
describe
(
'Production Usage'
,
()
=>
{
describe
(
'Production Usage'
,
()
=>
{
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
await
runNextCommand
([
'build'
,
appDir
],
{
await
runNextCommand
([
'build'
,
appDir
])
spawnOptions
:
{
env
:
{
...
process
.
env
,
NODE_ENV
:
'production'
}
}
})
app
=
nextServer
({
app
=
nextServer
({
dir
:
join
(
__dirname
,
'../'
),
dir
:
join
(
__dirname
,
'../'
),
dev
:
false
,
dev
:
false
,
...
...
test/lib/next-test-utils.js
View file @
a750d1cc
...
@@ -74,9 +74,12 @@ export function runNextCommand (argv, options = {}) {
...
@@ -74,9 +74,12 @@ export function runNextCommand (argv, options = {}) {
const
nextDir
=
path
.
dirname
(
require
.
resolve
(
'next/package'
))
const
nextDir
=
path
.
dirname
(
require
.
resolve
(
'next/package'
))
const
nextBin
=
path
.
join
(
nextDir
,
'dist/bin/next'
)
const
nextBin
=
path
.
join
(
nextDir
,
'dist/bin/next'
)
const
cwd
=
options
.
cwd
||
nextDir
const
cwd
=
options
.
cwd
||
nextDir
// Let Next.js decide the environment
const
env
=
{
...
process
.
env
,
...
options
.
env
,
NODE_ENV
:
undefined
}
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
`Running command "next
${
argv
.
join
(
' '
)}
"`
)
console
.
log
(
`Running command "next
${
argv
.
join
(
' '
)}
"`
)
const
instance
=
spawn
(
'node'
,
[
nextBin
,
...
argv
],
{
...
options
.
spawnOptions
,
cwd
,
stdio
:
[
'ignore'
,
'pipe'
,
'pipe'
]
})
const
instance
=
spawn
(
'node'
,
[
nextBin
,
...
argv
],
{
...
options
.
spawnOptions
,
cwd
,
env
,
stdio
:
[
'ignore'
,
'pipe'
,
'pipe'
]
})
if
(
typeof
options
.
instance
===
'function'
)
{
if
(
typeof
options
.
instance
===
'function'
)
{
options
.
instance
(
instance
)
options
.
instance
(
instance
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment