Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buildId being escaped causing getServerSideProps tests to be flakey #10728

Merged
merged 1 commit into from Feb 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 5 additions & 14 deletions test/integration/getserversideprops/test/index.test.js
Expand Up @@ -209,21 +209,15 @@ const runTests = (dev = false) => {
expect(JSON.parse(query)).toEqual({ path: ['first'] })

const data = JSON.parse(
await renderViaHTTP(
appPort,
`/_next/data/${escapeRegex(buildId)}/catchall/first.json`
)
await renderViaHTTP(appPort, `/_next/data/${buildId}/catchall/first.json`)
)

expect(data.pageProps.params).toEqual({ path: ['first'] })
})

it('should return data correctly', async () => {
const data = JSON.parse(
await renderViaHTTP(
appPort,
`/_next/data/${escapeRegex(buildId)}/something.json`
)
await renderViaHTTP(appPort, `/_next/data/${buildId}/something.json`)
)
expect(data.pageProps.world).toBe('world')
})
Expand All @@ -232,18 +226,15 @@ const runTests = (dev = false) => {
const data = JSON.parse(
await renderViaHTTP(
appPort,
`/_next/data/${escapeRegex(buildId)}/something.json?another=thing`
`/_next/data/${buildId}/something.json?another=thing`
)
)
expect(data.pageProps.query.another).toBe('thing')
})

it('should return data correctly for dynamic page', async () => {
const data = JSON.parse(
await renderViaHTTP(
appPort,
`/_next/data/${escapeRegex(buildId)}/blog/post-1.json`
)
await renderViaHTTP(appPort, `/_next/data/${buildId}/blog/post-1.json`)
)
expect(data.pageProps.post).toBe('post-1')
})
Expand Down Expand Up @@ -389,7 +380,7 @@ const runTests = (dev = false) => {
it('should set no-cache, no-store, must-revalidate header', async () => {
const res = await fetchViaHTTP(
appPort,
`/_next/data/${escapeRegex(buildId)}/something.json`
`/_next/data/${buildId}/something.json`
)
expect(res.headers.get('cache-control')).toContain('no-cache')
})
Expand Down