mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { retry } from 'next-test-utils'
|
|
|
|
describe('browser-log-forwarding warn level', () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
it('should forward warn and error logs to terminal', async () => {
|
|
const outputIndex = next.cliOutput.length
|
|
await next.browser('/')
|
|
|
|
await retry(() => {
|
|
const output = next.cliOutput.slice(outputIndex)
|
|
expect(output).toContain('browser error:')
|
|
expect(output).toContain('browser warn:')
|
|
})
|
|
|
|
// Get final output after logs are forwarded
|
|
const output = next.cliOutput.slice(outputIndex)
|
|
|
|
// Filter to only browser forwarded logs, excluding hydration noise
|
|
const browserLogs = output
|
|
.split('\n')
|
|
.filter(
|
|
(line) =>
|
|
line.includes('[browser]') &&
|
|
!line.includes('Next.js hydrate callback fire')
|
|
)
|
|
.join('\n')
|
|
|
|
expect(browserLogs).toMatchInlineSnapshot(`
|
|
"[browser] browser warn: this is a warning message (app/page.tsx:9:13)
|
|
[browser] browser error: this is an error message "
|
|
`)
|
|
})
|
|
})
|