Skip to content

Commit a69be6c

Browse files
authored
docs: Update README for experimental testmode (#75722)
- Fix the `npm` command - Make it clear where to place test files - Was reported here: #71773 - Relevant Next.js code: https://github.com/vercel/next.js/blob/ae5026a0fa8cd67f434cf63cc1db7d7ee696c047/packages/next/src/experimental/testmode/playwright/default-config.ts#L13 - Make it clear that `next.onFetch` only works for external requests. - Relevant Next.js code: https://github.com/vercel/next.js/blob/d2711d22fb719131d63cbce05a6306917f3626ea/packages/next/src/experimental/testmode/playwright/page-route.ts#L34-L40
1 parent 1dad3a6 commit a69be6c

File tree

1 file changed

+8
-1
lines changed
  • packages/next/src/experimental/testmode/playwright

1 file changed

+8
-1
lines changed

packages/next/src/experimental/testmode/playwright/README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { defineConfig } from 'next/experimental/testmode/playwright'
3535

3636
export default defineConfig({
3737
webServer: {
38-
command: 'npm dev',
38+
command: 'npm run dev',
3939
url: 'http://localhost:3000',
4040
},
4141
})
@@ -44,9 +44,16 @@ export default defineConfig({
4444
### Use the `next/experimental/testmode/playwright` to create tests
4545

4646
```javascript
47+
// Place this file in the `app` directory and name it with `.spec.ts`.
48+
// To customize where to put tests, add `testMatch` to `playwright.config.ts`.
49+
4750
import { test, expect } from 'next/experimental/testmode/playwright'
4851

4952
test('/product/shoe', async ({ page, next }) => {
53+
// NOTE: `next.onFetch` only intercepts external `fetch` requests (for both client and server).
54+
// For example, if you `fetch` a relative URL (e.g. `/api/hello`) from the client
55+
// that's handled by a Next.js route handler (e.g. `app/api/hello/route.ts`),
56+
// it won't be intercepted.
5057
next.onFetch((request) => {
5158
if (request.url === 'http://my-db/product/shoe') {
5259
return new Response(

0 commit comments

Comments
 (0)