Skip to content

Commit

Permalink
Update warn -> Error and check exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jan 17, 2020
1 parent 2faa022 commit 1103555
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/next/export/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default async function({
const queryWithAutoExportWarn = () => {
if (hasOrigQueryValues) {
throw new Error(
`\nWarn: you provided query values for ${path} which is an auto-exported page. These can not be applied since the page can no longer be re-rendered on the server. To disable auto-export for this page add \`getInitialProps\`\n`
`\nError: you provided query values for ${path} which is an auto-exported page. These can not be applied since the page can no longer be re-rendered on the server. To disable auto-export for this page add \`getInitialProps\`\n`
)
}
}
Expand Down
10 changes: 7 additions & 3 deletions test/integration/auto-export-query-error/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ const appDir = path.join(__dirname, '..')
const outdir = path.join(__dirname, 'out')
const nextConfig = path.join(appDir, 'next.config.js')
let stderr
let exitCode

const runTests = () => {
it('should show warning for query provided for auto exported page correctly', async () => {
expect(exitCode).toBe(1)
expect(stderr).toContain(
'Warn: you provided query values for / which is an auto-exported page. These can not be applied since the page can no longer be re-rendered on the server. To disable auto-export for this page add `getInitialProps`'
'Error: you provided query values for / which is an auto-exported page. These can not be applied since the page can no longer be re-rendered on the server. To disable auto-export for this page add `getInitialProps`'
)

expect(stderr).not.toContain('/amp')
Expand All @@ -29,12 +31,13 @@ describe('Auto Export', () => {
describe('server mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
const { stderr: curStderr } = await nextExport(
const { stderr: curStderr, code: curCode } = await nextExport(
appDir,
{ outdir },
{ stderr: true }
)
stderr = curStderr
exitCode = curCode
})

runTests()
Expand All @@ -44,12 +47,13 @@ describe('Auto Export', () => {
beforeAll(async () => {
origNextConfig = await fs.readFile(nextConfig, 'utf8')
await nextBuild(appDir)
const { stderr: curStderr } = await nextExport(
const { stderr: curStderr, code: curCode } = await nextExport(
appDir,
{ outdir },
{ stderr: true }
)
stderr = curStderr
exitCode = curCode
})
afterAll(async () => {
await fs.writeFile(nextConfig, origNextConfig)
Expand Down
3 changes: 2 additions & 1 deletion test/lib/next-test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ export function runNextCommand(argv, options = {}) {
})
}

instance.on('close', () => {
instance.on('close', code => {
resolve({
code,
stdout: stdoutOutput,
stderr: stderrOutput,
})
Expand Down

0 comments on commit 1103555

Please sign in to comment.