Skip to content

Commit 0b5e97e

Browse files
committed
[test] Reduce flakiness of instrumentation-order
1 parent f61bfa7 commit 0b5e97e

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed
Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
11
import { nextTestSetup } from 'e2e-utils'
2-
import { waitFor } from 'next-test-utils'
3-
4-
const ORDERED_LOGS = [
5-
'instrumentation:side-effect',
6-
'instrumentation:register:begin',
7-
'instrumentation:register:timeout',
8-
'instrumentation:register:end',
9-
'global-side-effect:app-router-page',
10-
]
2+
import { retry } from 'next-test-utils'
113

124
describe('instrumentation-order', () => {
13-
const { next, isNextDev } = nextTestSetup({
5+
const { next } = nextTestSetup({
146
files: __dirname,
157
skipDeployment: true,
168
})
179

18-
it('should work using cheerio', async () => {
19-
// Wait for the timeout in the instrumentation to complete
20-
await waitFor(500)
10+
it('should work', async () => {
11+
await next.fetch('/')
2112

22-
// Dev mode requires to render the page to trigger the build of the page
23-
if (isNextDev) {
24-
await next.render$('/')
25-
}
13+
await retry(async () => {
14+
const serverLog = next.cliOutput.split('Starting...')[1]
15+
const cliOutputLines = serverLog.split('\n')
2616

27-
const serverLog = next.cliOutput.split('Starting...')[1]
28-
const cliOutputLines = serverLog.split('\n')
29-
const searchedLines = cliOutputLines.filter((line) =>
30-
ORDERED_LOGS.includes(line.trim())
31-
)
17+
const ORDERED_LOGS = [
18+
'instrumentation:side-effect',
19+
'instrumentation:register:begin',
20+
'instrumentation:register:timeout',
21+
'instrumentation:register:end',
22+
'global-side-effect:app-router-page',
23+
]
24+
const searchedLines = cliOutputLines.filter((line) =>
25+
ORDERED_LOGS.includes(line.trim())
26+
)
3227

33-
expect(searchedLines).toEqual(ORDERED_LOGS)
28+
expect(searchedLines).toEqual(ORDERED_LOGS)
29+
})
3430
})
3531
})
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/**
22
* @type {import('next').NextConfig}
33
*/
4-
const nextConfig = {}
4+
const nextConfig = {
5+
experimental: {
6+
preloadEntriesOnStart: false,
7+
},
8+
}
59

610
module.exports = nextConfig

0 commit comments

Comments
 (0)