Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update README for experimental testmode #75722

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/next/src/experimental/testmode/playwright/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { defineConfig } from 'next/experimental/testmode/playwright'

export default defineConfig({
webServer: {
command: 'npm dev',
command: 'npm run dev',
url: 'http://localhost:3000',
},
})
Expand All @@ -44,9 +44,16 @@ export default defineConfig({
### Use the `next/experimental/testmode/playwright` to create tests

```javascript
// Place this file in the `app` directory and name it with `.spec.ts`.
// To customize where to put tests, add `testMatch` to `playwright.config.ts`.

import { test, expect } from 'next/experimental/testmode/playwright'

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