Unverified Commit 7c458922 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[test] Reduce flakiness of instrumentation-order (#80712)

The test was implicitly relying on `preloadEntriesOnStart` to load the module in our prod tests.

Fixes https://github.com/vercel/next.js/actions/runs/15774186781/job/44464850249?pr=80710#step:34:282 and [other flakes](https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40test.source.file%3A%22test%2Fe2e%2Fapp-dir%2Finstrumentation-order%2Finstrumentation-order.test.ts%22%20%40test.status%3Afail&agg_m=count&agg_m_source=base&agg_t=count&currentTab=overview&eventStack=&fromUser=true&index=citest&start=1749804083936&end=1750408883936&paused=true)

Now we always trigger the page for the first time in the test and wait for the logs to come in instead of hardcoding a timeout.
parent ce5796a9
import { nextTestSetup } from 'e2e-utils'
import { waitFor } from 'next-test-utils'
const ORDERED_LOGS = [
'instrumentation:side-effect',
'instrumentation:register:begin',
'instrumentation:register:timeout',
'instrumentation:register:end',
'global-side-effect:app-router-page',
]
import { retry } from 'next-test-utils'
describe('instrumentation-order', () => {
const { next, isNextDev } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
it('should work using cheerio', async () => {
// Wait for the timeout in the instrumentation to complete
await waitFor(500)
it('should work', async () => {
await next.fetch('/')
// Dev mode requires to render the page to trigger the build of the page
if (isNextDev) {
await next.render$('/')
}
await retry(async () => {
const serverLog = next.cliOutput.split('Starting...')[1]
const cliOutputLines = serverLog.split('\n')
const serverLog = next.cliOutput.split('Starting...')[1]
const cliOutputLines = serverLog.split('\n')
const searchedLines = cliOutputLines.filter((line) =>
ORDERED_LOGS.includes(line.trim())
)
const ORDERED_LOGS = [
'instrumentation:side-effect',
'instrumentation:register:begin',
'instrumentation:register:timeout',
'instrumentation:register:end',
'global-side-effect:app-router-page',
]
const searchedLines = cliOutputLines.filter((line) =>
ORDERED_LOGS.includes(line.trim())
)
expect(searchedLines).toEqual(ORDERED_LOGS)
expect(searchedLines).toEqual(ORDERED_LOGS)
})
})
})
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}
const nextConfig = {
experimental: {
preloadEntriesOnStart: false,
},
}
module.exports = nextConfig
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment