|
1 | 1 | 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' |
11 | 3 |
|
12 | 4 | describe('instrumentation-order', () => {
|
13 |
| - const { next, isNextDev } = nextTestSetup({ |
| 5 | + const { next } = nextTestSetup({ |
14 | 6 | files: __dirname,
|
15 | 7 | skipDeployment: true,
|
16 | 8 | })
|
17 | 9 |
|
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('/') |
21 | 12 |
|
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') |
26 | 16 |
|
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 | + ) |
32 | 27 |
|
33 |
| - expect(searchedLines).toEqual(ORDERED_LOGS) |
| 28 | + expect(searchedLines).toEqual(ORDERED_LOGS) |
| 29 | + }) |
34 | 30 | })
|
35 | 31 | })
|
0 commit comments