mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
### 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 -->
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { nextTestSetup, type Playwright } from 'e2e-utils'
|
|
|
|
describe('Custom Resolver Tests', () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
type Browser = Playwright
|
|
|
|
function runTests(browser: () => Browser) {
|
|
it('Should use a custom resolver for image URL', async () => {
|
|
expect(
|
|
await browser().elementById('basic-image').getAttribute('src')
|
|
).toBe('https://customresolver.com/foo.jpg?w~~1024,q~~60')
|
|
})
|
|
it('should add a srcset based on the custom resolver', async () => {
|
|
expect(
|
|
await browser().elementById('basic-image').getAttribute('srcset')
|
|
).toBe(
|
|
'https://customresolver.com/foo.jpg?w~~480,q~~60 1x, https://customresolver.com/foo.jpg?w~~1024,q~~60 2x'
|
|
)
|
|
})
|
|
it('should support the unoptimized attribute', async () => {
|
|
expect(
|
|
await browser().elementById('unoptimized-image').getAttribute('src')
|
|
).toBe('https://arbitraryurl.com/foo.jpg')
|
|
})
|
|
}
|
|
|
|
describe('SSR Custom Loader Tests', () => {
|
|
let browser: Playwright
|
|
beforeAll(async () => {
|
|
browser = await next.browser('/')
|
|
})
|
|
runTests(() => browser)
|
|
})
|
|
|
|
describe('Client-side Custom Loader Tests', () => {
|
|
let browser: Playwright
|
|
beforeAll(async () => {
|
|
browser = await next.browser('/client-side')
|
|
})
|
|
runTests(() => browser)
|
|
})
|
|
})
|