Skip to content

Commit 1db925a

Browse files
authored
[test] Deflake custom cache handler test (#85610)
[flakiness metric](https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40git.repository.id%3A%22github.com%2Fvercel%2Fnext.js%22%20%40test.name%3A%22use-cache-custom-handler%20should%20use%20a%20modern%20custom%20cache%20handler%20if%20provided%22%20%40test.type%3A%22nextjs%22%20%40test.status%3A%22fail%22%20%40git.branch%3Acanary&agg_m=count&agg_m_source=base&agg_t=count&fromUser=true&index=citest&start=1759310750664&end=1761902750664&paused=false) The test page used a low revalidate time of 3 seconds. In CI, sometimes that much time passes between the first and second request, causing the test to fail when comparing the data values (locally reproducible with `{ cpuThrottleRate: 20 }`). Increasing the revalidate time to 6 seconds should make the test more robust.
1 parent bfe2ab4 commit 1db925a

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

test/e2e/app-dir/use-cache-custom-handler/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React from 'react'
77
async function getData() {
88
'use cache'
99

10-
cacheLife({ revalidate: 3 })
10+
cacheLife({ revalidate: 6 })
1111
cacheTag('modern')
1212

1313
return new Date().toISOString()

test/e2e/app-dir/use-cache-custom-handler/use-cache-custom-handler.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,16 @@ describe('use-cache-custom-handler', () => {
5858
// Because we use a low `revalidate` value for the "use cache" function, new
5959
// data should be returned eventually.
6060

61-
await retry(async () => {
62-
await browser.refresh()
63-
data = await browser.elementById('data').text()
64-
expect(data).toMatch(isoDateRegExp)
65-
expect(data).not.toEqual(initialData)
66-
}, 5000)
61+
await retry(
62+
async () => {
63+
await browser.refresh()
64+
data = await browser.elementById('data').text()
65+
expect(data).toMatch(isoDateRegExp)
66+
expect(data).not.toEqual(initialData)
67+
},
68+
10_000,
69+
2_000
70+
)
6771
})
6872

6973
it('calls neither refreshTags nor getExpiration if "use cache" is not used', async () => {

0 commit comments

Comments
 (0)