mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
e860cec656
### 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 -->
74 lines
1.9 KiB
TypeScript
74 lines
1.9 KiB
TypeScript
import { FileRef, nextTestSetup } from 'e2e-utils'
|
|
import { join } from 'path'
|
|
import {
|
|
waitForRedbox,
|
|
waitForNoRedbox,
|
|
getRedboxSource,
|
|
} from 'next-test-utils'
|
|
|
|
// TODO: The error overlay is not closed when restoring the working code.
|
|
describe.skip('next/font build-errors', () => {
|
|
const { next } = nextTestSetup({
|
|
files: new FileRef(join(__dirname, 'build-errors')),
|
|
})
|
|
|
|
it('should show a next/font error when input is wrong', async () => {
|
|
const browser = await next.browser('/')
|
|
const content = await next.readFile('app/page.js')
|
|
|
|
await next.patchFile(
|
|
'app/page.js',
|
|
`
|
|
import localFont from 'next/font/local'
|
|
|
|
const font = localFont()
|
|
|
|
export default function Page() {
|
|
return <p className={font.className}>Hello world!</p>
|
|
}
|
|
`
|
|
)
|
|
|
|
await waitForRedbox(browser)
|
|
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
|
|
"app/page.js
|
|
\`next/font\` error:
|
|
Missing required \`src\` property"
|
|
`)
|
|
|
|
await next.patchFile('app/page.js', content)
|
|
await waitForNoRedbox(browser)
|
|
})
|
|
|
|
it("should show a module not found error if local font file can' be resolved", async () => {
|
|
const browser = await next.browser('/')
|
|
const content = await next.readFile('app/page.js')
|
|
|
|
await next.patchFile(
|
|
'app/page.js',
|
|
`
|
|
import localFont from 'next/font/local'
|
|
|
|
const font = localFont({ src: './boom.woff2'})
|
|
|
|
export default function Page() {
|
|
return <p className={font.className}>Hello world!</p>
|
|
}
|
|
`
|
|
)
|
|
|
|
await waitForRedbox(browser)
|
|
const sourceLines = (await getRedboxSource(browser)).split('\n')
|
|
|
|
// Should display the file name correctly
|
|
expect(sourceLines[0]).toEqual('app/page.js')
|
|
// Should be module not found error
|
|
expect(sourceLines[1]).toEqual(
|
|
"Module not found: Can't resolve './boom.woff2'"
|
|
)
|
|
|
|
await next.patchFile('app/page.js', content)
|
|
await waitForNoRedbox(browser)
|
|
})
|
|
})
|