Skip to content

Commit

Permalink
Throw error instead of logging to make sure it's noticed
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 28, 2019
1 parent 98f1f59 commit f3db0a0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/next/next-server/server/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export async function renderToHTML(
}

if (!!unstable_getStaticParams && !isSpr) {
console.error(
throw new Error(
`unstable_getStaticParams was added without a unstable_getStaticProps in ${pathname}. Without unstable_getStaticProps, unstable_getStaticParams does nothing`
)
}
Expand Down
6 changes: 0 additions & 6 deletions test/integration/prerender/pages/no-getStaticProps.js

This file was deleted.

19 changes: 17 additions & 2 deletions test/integration/prerender/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,24 @@ const runTests = (dev = false) => {
})

it('should show error when getStaticParams is used without getStaticProps', async () => {
await renderViaHTTP(appPort, '/no-getStaticProps')
const pagePath = join(appDir, 'pages/no-getStaticProps.js')
await fs.writeFile(
pagePath,
`
export async function unstable_getStaticParams() {
return []
}
export default () => 'hi'
`,
'utf8'
)

const html = await renderViaHTTP(appPort, '/no-getStaticProps')
await fs.remove(pagePath)
await waitFor(500)
expect(stderr).toMatch(

expect(html).toMatch(
/unstable_getStaticParams was added without a unstable_getStaticProps in/
)
})
Expand Down

0 comments on commit f3db0a0

Please sign in to comment.