Files
Tim NeutkensandGitHub e860cec656 test: migrate webdriver callers to next.browser (#93941)
### What?

Migrate remaining direct `next-webdriver` test callers that have a
`NextInstance` to `next.browser()`, and expose the shared `Playwright`
browser type from `e2e-utils`.

### Why?

`NextInstance.browser` should be the supported browser-opening interface
for test fixtures, with `next-webdriver` kept as the private
implementation detail.

### How?

Updated affected development, e2e, and production tests to call
`next.browser()` directly, passing `baseUrl` where tests intentionally
target a manually spawned or proxied server. Shared helpers now receive
browser callbacks from the test context, and browser types import
`Playwright` from `e2e-utils` instead of deriving from `next.browser` or
importing from private paths.

<!-- NEXT_JS_LLM_PR -->
2026-05-22 14:01:58 +02:00

49 lines
1.7 KiB
TypeScript

import { FileRef, nextTestSetup } from 'e2e-utils'
import { check, renderViaHTTP, waitFor } from 'next-test-utils'
import { join } from 'path'
describe('fatal-render-error', () => {
const { next } = nextTestSetup({
files: new FileRef(join(__dirname, 'app')),
dependencies: {},
})
it('should render page without error correctly', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('index page')
expect(html).toContain('from _app')
})
it('should handle fatal error in _app and _error without loop on direct visit', async () => {
const browser = await next.browser('/with-error')
// wait a bit to see if we are rendering multiple times unexpectedly
await waitFor(500)
expect(await browser.eval('window.renderAttempts')).toBeLessThan(10)
const html = await browser.eval('document.documentElement.innerHTML')
expect(html).not.toContain('from _app')
expect(html).toContain(
'Application error: a client-side exception has occurred'
)
})
it('should handle fatal error in _app and _error without loop on client-transition', async () => {
const browser = await next.browser('/')
await browser.eval('window.renderAttempts = 0')
await browser.eval('window.next.router.push("/with-error")')
await check(() => browser.eval('location.pathname'), '/with-error')
// wait a bit to see if we are rendering multiple times unexpectedly
await waitFor(500)
expect(await browser.eval('window.renderAttempts')).toBeLessThan(10)
const html = await browser.eval('document.documentElement.innerHTML')
expect(html).not.toContain('from _app')
expect(html).toContain(
'Application error: a client-side exception has occurred'
)
})
})