@next/playwright 16.5.0-canary.7 → 16.5.0-canary.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +20 -4
  2. package/license.md +21 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # @next/playwright
2
2
 
3
3
  > - **Status:** Experimental. This API is not yet stable.
4
- > - **Requires:** [Cache Components](https://nextjs.org/docs) to be enabled.
4
+ > - **Requires:** [Cache Components](https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents) to be enabled.
5
5
 
6
6
  Playwright helpers for testing Next.js applications.
7
7
 
8
+ See the [Playwright guide](https://nextjs.org/docs/app/guides/testing/playwright#testing-instant-navigations)
9
+ for installation, parameters, initial page loads, and navigation caveats.
10
+
8
11
  ## Instant Navigation Testing
9
12
 
10
13
  An **instant navigation** commits immediately without waiting for data fetching.
@@ -18,16 +21,19 @@ deferred until the callback returns. This lets you make deterministic assertions
18
21
  against the shell without race conditions.
19
22
 
20
23
  The tool assumes a warm cache: all prefetches have completed and all cacheable
21
- data is available. This way you're testing whether the route is *structured
22
- correctly* for instant navigation, independent of network timing. If content you
24
+ data is available. This way you're testing whether the route is _structured
25
+ correctly_ for instant navigation, independent of network timing. If content you
23
26
  expected to be cached is missing inside the callback, it points to a problem — a
24
27
  missing `use cache` directive, a misplaced Suspense boundary, or a similar gap.
28
+ For [same-page search-parameter updates](https://nextjs.org/docs/app/guides/testing/playwright#search-parameter-updates),
29
+ waiting for fresh data can be intentional.
25
30
 
26
31
  ### Examples
27
32
 
28
33
  **Loading shell appears instantly** (dynamic content behind a Suspense boundary):
29
34
 
30
35
  ```ts
36
+ import { expect, test } from '@playwright/test'
31
37
  import { instant } from '@next/playwright'
32
38
 
33
39
  test('shows loading shell during navigation', async ({ page }) => {
@@ -35,6 +41,7 @@ test('shows loading shell during navigation', async ({ page }) => {
35
41
 
36
42
  await instant(page, async () => {
37
43
  await page.click('a[href="/dashboard"]')
44
+ await page.waitForURL((url) => url.pathname === '/dashboard')
38
45
 
39
46
  // The loading shell is visible — dynamic data is deferred
40
47
  await expect(page.locator('[data-testid="loading"]')).toBeVisible()
@@ -48,11 +55,15 @@ test('shows loading shell during navigation', async ({ page }) => {
48
55
  **Fully instant navigation** (all content is cached):
49
56
 
50
57
  ```ts
58
+ import { expect, test } from '@playwright/test'
59
+ import { instant } from '@next/playwright'
60
+
51
61
  test('navigates to profile instantly', async ({ page }) => {
52
62
  await page.goto('/')
53
63
 
54
64
  await instant(page, async () => {
55
65
  await page.click('a[href="/profile"]')
66
+ await page.waitForURL((url) => url.pathname === '/profile')
56
67
 
57
68
  // All content renders immediately
58
69
  await expect(page.locator('[data-testid="profile-name"]')).toBeVisible()
@@ -64,11 +75,13 @@ test('navigates to profile instantly', async ({ page }) => {
64
75
  ### Enabling in production builds
65
76
 
66
77
  In development (`next dev`), the testing API is available by default. In
67
- production builds, it is disabled unless you explicitly opt in:
78
+ production builds, it is disabled unless you explicitly opt in during both
79
+ `next build` and `next start`:
68
80
 
69
81
  ```js
70
82
  // next.config.js
71
83
  module.exports = {
84
+ cacheComponents: true,
72
85
  experimental: {
73
86
  exposeTestingApiInProductionBuild: true,
74
87
  },
@@ -105,3 +118,6 @@ document.cookie = 'next-instant-navigation-testing=1; path=/'
105
118
  // Clear the cookie to resume normal behavior
106
119
  document.cookie = 'next-instant-navigation-testing=; path=/; max-age=0'
107
120
  ```
121
+
122
+ See the [helper implementation](https://github.com/vercel/next.js/blob/canary/packages/next-playwright/src/index.ts)
123
+ for browser-context cookie handling and cleanup when assertions fail.
package/license.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Vercel, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next/playwright",
3
- "version": "16.5.0-canary.7",
3
+ "version": "16.5.0-canary.70",
4
4
  "repository": {
5
5
  "url": "vercel/next.js",
6
6
  "directory": "packages/next-playwright"