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

85 lines
2.5 KiB
TypeScript

import path from 'path'
import { FileRef, nextTestSetup } from 'e2e-utils'
describe('transpile packages', () => {
if ((global as any).isNextDeploy) {
it('should skip for deploy mode for now', () => {})
return
}
const { next } = nextTestSetup({
files: new FileRef(path.join(__dirname, './npm')),
dependencies: {
sass: 'latest',
},
})
const { isNextDeploy } = global as any
if (isNextDeploy) {
it('should skip tests for next-deploy and react 17', () => {})
return
}
// TODO: This test is failing in Turbopack
it.skip('should handle optional peer dependencies', async () => {
const browser = await next.browser('/peer-deps')
expect(await browser.elementByCss('h1').text()).toBe('world')
})
describe('css', () => {
it('should handle global css imports inside transpiled modules', async () => {
const browser = await next.browser('/global-css')
expect(
await browser.eval(
`window.getComputedStyle(document.querySelector('body')).backgroundColor`
)
).toBe('rgb(0, 0, 255)')
})
it('should handle global scss imports inside transpiled modules', async () => {
const browser = await next.browser('/global-scss')
expect(
await browser.eval(
`window.getComputedStyle(document.querySelector('body')).backgroundColor`
)
).toBe('rgb(0, 0, 255)')
})
it('should handle css modules imports inside transpiled modules', async () => {
const browser = await next.browser('/css-modules')
expect(
await browser.eval(
`window.getComputedStyle(document.querySelector('h1')).backgroundColor`
)
).toBe('rgb(0, 0, 255)')
})
it('should handle scss modules imports inside transpiled modules', async () => {
const browser = await next.browser('/scss-modules')
expect(
await browser.eval(
`window.getComputedStyle(document.querySelector('h1')).backgroundColor`
)
).toBe('rgb(0, 0, 255)')
})
})
describe('optional deps', () => {
it('should not throw an error when optional deps are not installed', async () => {
expect(next.cliOutput).not.toContain(
"Module not found: Error: Can't resolve 'foo'"
)
})
it('should hide dynammic module dependency errors from node_modules', async () => {
expect(next.cliOutput).not.toContain(
'Critical dependency: the request of a dependency is an expression'
)
})
})
})