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

35 lines
1.1 KiB
TypeScript

import { FileRef, nextTestSetup } from 'e2e-utils'
import { join } from 'path'
import { check } from 'next-test-utils'
describe('browser-shallow-navigation', () => {
const { next } = nextTestSetup({
files: {
pages: new FileRef(join(__dirname, 'app/pages')),
'middleware.js': new FileRef(join(__dirname, 'app/middleware.js')),
},
})
it('should render the correct page', async () => {
const browser = await next.browser('/')
/// do shallow push
await browser.elementByCss('[data-next-shallow-push]').click()
await browser.waitForElementByCss('[data-next-page]')
// go to another page
await browser.elementByCss('[data-next-page]').click()
await browser.waitForElementByCss('[data-next-shallow-replace]')
// do shadow replace
await browser.elementByCss('[data-next-shallow-replace]').click()
await browser.waitForElementByCss('[data-go-back]')
// go back using history api
await browser.elementByCss('[data-go-back]').click()
// get page h1
await check(() => browser.elementByCss('h1').text(), /Content for page 1/)
})
})