rsnext/packages
Andrew Gadzik 4c467a2638
Improve experimental test proxy (#63567)
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>
2024-03-21 21:31:29 +00:00
..
create-next-app v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
eslint-config-next v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
eslint-plugin-next v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
font v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
next Improve experimental test proxy (#63567) 2024-03-21 21:31:29 +00:00
next-bundle-analyzer v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
next-codemod v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
next-env v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
next-mdx v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
next-plugin-storybook v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
next-polyfill-module v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
next-polyfill-nomodule v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
next-swc v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
react-refresh-utils v14.2.0-canary.35 2024-03-21 17:49:30 +00:00
third-parties v14.2.0-canary.35 2024-03-21 17:49:30 +00:00