Skip to content

Commit 09229fe

Browse files
committed
Add failing test for re-calling getStaticProps after updating query
1 parent d55b464 commit 09229fe

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

test/integration/prerender/pages/something.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default ({ world, time, params, random }) => {
2020
<>
2121
<p>hello: {world}</p>
2222
<span>time: {time}</span>
23-
<div>{random}</div>
23+
<div id="random">{random}</div>
2424
<div id="params">{JSON.stringify(params)}</div>
2525
<div id="query">{JSON.stringify(useRouter().query)}</div>
2626
<Link href="/">

test/integration/prerender/test/index.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,23 @@ const runTests = (dev = false) => {
340340
await fs.writeFile(indexPage, origContent)
341341
}
342342
})
343+
344+
it('should not re-call getStaticProps when updating query', async () => {
345+
const browser = await webdriver(appPort, '/something?hello=world')
346+
await waitFor(2000)
347+
348+
const query = await browser.elementByCss('#query').text()
349+
expect(JSON.parse(query)).toEqual({ hello: 'world' })
350+
351+
const {
352+
props: {
353+
pageProps: { random: initialRandom },
354+
},
355+
} = await browser.eval('window.__NEXT_DATA__')
356+
357+
const curRandom = await browser.elementByCss('#random').text()
358+
expect(curRandom).toBe(initialRandom + '')
359+
})
343360
} else {
344361
it('should should use correct caching headers for a no-revalidate page', async () => {
345362
const initialRes = await fetchViaHTTP(appPort, '/something')

0 commit comments

Comments
 (0)