Skip to content

Commit

Permalink
Fix message on getStaticPaths conflict with getServerSideProps (verce…
Browse files Browse the repository at this point in the history
…l#13874)

* initial

* Update tests

Co-authored-by: Joe Haddad <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and rokinsky committed Jul 11, 2020
1 parent 952a5a2 commit f58ea6e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const SSG_GET_INITIAL_PROPS_CONFLICT = `You can not use getInitialProps w

export const SERVER_PROPS_GET_INIT_PROPS_CONFLICT = `You can not use getInitialProps with getServerSideProps. Please remove getInitialProps.`

export const SERVER_PROPS_SSG_CONFLICT = `You can not use getStaticProps with getServerSideProps. To use SSG, please remove getServerSideProps`
export const SERVER_PROPS_SSG_CONFLICT = `You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps`

export const PAGES_404_GET_INITIAL_PROPS_ERROR = `\`pages/404\` can not have getInitialProps/getServerSideProps, https://err.sh/next.js/404-get-initial-props`

Expand Down
38 changes: 38 additions & 0 deletions test/unit/babel-plugin-next-ssg-transform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,5 +498,43 @@ describe('babel plugin (next-ssg-transform)', () => {
`"import other from'other';const[foo]=other;export var __N_SSG=true;export default function Home(){return __jsx(\\"div\\",null);}"`
)
})

it('errors for incorrect mix of functions', () => {
expect(() =>
babel(trim`
export function getStaticProps() {}
export function getServerSideProps() {}
`)
).toThrowError(
`You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps`
)

expect(() =>
babel(trim`
export function getServerSideProps() {}
export function getStaticProps() {}
`)
).toThrowError(
`You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps`
)

expect(() =>
babel(trim`
export function getStaticPaths() {}
export function getServerSideProps() {}
`)
).toThrowError(
`You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps`
)

expect(() =>
babel(trim`
export function getServerSideProps() {}
export function getStaticPaths() {}
`)
).toThrowError(
`You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps`
)
})
})
})

0 comments on commit f58ea6e

Please sign in to comment.