4c467a2638
Followup on https://github.com/vercel/next.js/pull/52520 and https://github.com/vercel/next.js/pull/54014 **Enhancements** - Removes `--experimental-test-proxy` CLI argument from `next dev` and `next start` - Adds a new experimental config option `testProxy?: boolean` - Instead of throwing an error, return the `originalFetch` response if the current request context does not contain the `Next-Test-*` HTTP headers **Why?** These changes allow us to write mixed Integration + E2E tests within the same Playwright process. ```ts // some-page.spec.ts test.describe('/some-page', () => { test('some integration test', async ({ page, next }) => { // by using the `next` fixture, playwright will send the `Next-Test-*` HTTP headers for // every request in this test's context. next.onFetch(...); await page.goto(...); await expect(...).toBe('some-mocked-value'); }); test('some e2e test', async ({ page }) => { // by NOT using the `next` fixture, playwright does not send the `Next-Test-*` HTTP headers await page.goto(...); await expect(...).toBe('some-real-value'); }); }) ``` Now I can run `next dev` and locally develop my App Router pages AND run my Playwright tests against instead of having to, - run `next dev` to locally develop my change - ctrl+c to kill server - run `next dev --experimental-test-proxy` to locally run my integration tests --------- Co-authored-by: Sam Ko <sam@vercel.com>
14 lines
236 B
JavaScript
14 lines
236 B
JavaScript
/** @type {import('next').NextConfig} */
|
|
module.exports = {
|
|
experimental: {
|
|
testProxy: true,
|
|
},
|
|
rewrites() {
|
|
return [
|
|
{
|
|
source: '/rewrite-1',
|
|
destination: 'https://example.com',
|
|
},
|
|
]
|
|
},
|
|
}
|