mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +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 -->
75 lines
2.1 KiB
TypeScript
75 lines
2.1 KiB
TypeScript
import { join } from 'path'
|
|
import { FileRef, nextTestSetup } from 'e2e-utils'
|
|
import { check } from 'next-test-utils'
|
|
|
|
describe('Legacy decorators SWC option', () => {
|
|
describe('with extended tsconfig', () => {
|
|
const { next } = nextTestSetup({
|
|
files: {
|
|
'tsconfig.json': new FileRef(
|
|
join(__dirname, 'legacy-decorators/tsconfig-extended.json')
|
|
),
|
|
'tsconfig-base.json': new FileRef(
|
|
join(__dirname, 'legacy-decorators/jsconfig.json')
|
|
),
|
|
pages: new FileRef(join(__dirname, 'legacy-decorators/pages')),
|
|
},
|
|
dependencies: {
|
|
mobx: '6.3.7',
|
|
'mobx-react': '7.2.1',
|
|
},
|
|
})
|
|
|
|
it('should compile with legacy decorators enabled from extended config', async () => {
|
|
let browser
|
|
try {
|
|
browser = await next.browser('/')
|
|
const text = await browser.elementByCss('#count').text()
|
|
expect(text).toBe('Current number: 0')
|
|
await browser.elementByCss('#increase').click()
|
|
await check(
|
|
() => browser.elementByCss('#count').text(),
|
|
/Current number: 1/
|
|
)
|
|
} finally {
|
|
if (browser) {
|
|
await browser.close()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
describe('with base config', () => {
|
|
const { next } = nextTestSetup({
|
|
files: {
|
|
'jsconfig.json': new FileRef(
|
|
join(__dirname, 'legacy-decorators/jsconfig.json')
|
|
),
|
|
pages: new FileRef(join(__dirname, 'legacy-decorators/pages')),
|
|
},
|
|
dependencies: {
|
|
mobx: '6.3.7',
|
|
'mobx-react': '7.2.1',
|
|
},
|
|
})
|
|
|
|
it('should compile with legacy decorators enabled', async () => {
|
|
let browser
|
|
try {
|
|
browser = await next.browser('/')
|
|
const text = await browser.elementByCss('#count').text()
|
|
expect(text).toBe('Current number: 0')
|
|
await browser.elementByCss('#increase').click()
|
|
await check(
|
|
() => browser.elementByCss('#count').text(),
|
|
/Current number: 1/
|
|
)
|
|
} finally {
|
|
if (browser) {
|
|
await browser.close()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
})
|