Repository: vercel/next.js
Pull request: Revert "Upgrade @playwright/test and cleanup internal APIs"

Reverts vercel/next.js#77659

[x-ref](https://vercel.slack.com/archives/C03KAR5DCKC/p1743745064109939?thread_ts=1743528456.364379&cid=C03KAR5DCKC)

Changed files:
filename: packages/next/package.json
patch: @@ -110,7 +110,7 @@
   },
   "peerDependencies": {
     "@opentelemetry/api": "^1.1.0",
-    "@playwright/test": "^1.51.1",
+    "@playwright/test": "^1.41.2",
     "babel-plugin-react-compiler": "*",
     "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",
     "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",
@@ -170,7 +170,7 @@
     "@next/react-refresh-utils": "15.3.0-canary.34",
     "@next/swc": "15.3.0-canary.34",
     "@opentelemetry/api": "1.6.0",
-    "@playwright/test": "1.51.1",
+    "@playwright/test": "1.41.2",
     "@storybook/addon-a11y": "8.6.0",
     "@storybook/addon-essentials": "8.6.0",
     "@storybook/addon-interactions": "8.6.0",

filename: packages/next/src/experimental/testmode/playwright/step.ts
patch: @@ -9,13 +9,33 @@ export interface StepProps {
   params?: Record<string, string | number | boolean | null | undefined>
 }
 
+// Access the internal Playwright API until it's exposed publicly.
+// See https://github.com/microsoft/playwright/issues/27059.
+interface TestInfoWithRunAsStep extends TestInfo {
+  _runAsStep: <T>(
+    stepInfo: StepProps,
+    handler: (result: { complete: Complete }) => Promise<T>
+  ) => Promise<T>
+}
+
 type Complete = (result: { error?: any }) => void
 
+function isWithRunAsStep(
+  testInfo: TestInfo
+): testInfo is TestInfoWithRunAsStep {
+  return '_runAsStep' in testInfo
+}
+
 export async function step<T>(
-  _testInfo: TestInfo,
+  testInfo: TestInfo,
   props: StepProps,
   handler: (complete: Complete) => Promise<Awaited<T>>
 ): Promise<Awaited<T>> {
+  if (isWithRunAsStep(testInfo)) {
+    return testInfo._runAsStep(props, ({ complete }) => handler(complete))
+  }
+
+  // Fallback to the `test.step()`.
   let result: Awaited<T>
   let reportedError: any
   try {

filename: pnpm-lock.yaml
patch: @@ -1036,8 +1036,8 @@ importers:
         specifier: 1.6.0
         version: 1.6.0
       '@playwright/test':
-        specifier: 1.51.1
-        version: 1.51.1
+        specifier: 1.41.2
+        version: 1.41.2
       '@storybook/addon-a11y':
         specifier: 8.6.0
         version: 8.6.0(storybook@8.6.0(prettier@3.3.3))
@@ -1211,7 +1211,7 @@ importers:
         version: 3.0.0
       axe-playwright:
         specifier: 2.0.3
-        version: 2.0.3(playwright@1.51.1)
+        version: 2.0.3(playwright@1.48.0)
       babel-plugin-react-compiler:
         specifier: 19.0.0-beta-e552027-20250112
         version: 19.0.0-beta-e552027-20250112
@@ -5067,9 +5067,10 @@ packages:
     resolution: {integrity: sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==}
     engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
 
-  '@playwright/test@1.51.1':
-    resolution: {integrity: sha512-nM+kEaTSAoVlXmMPH10017vn3FSiFqr/bh4fKg9vmAdMfd9SDqRZNvPSiAHADc/itWak+qPvMPZQOPwCBW7k7Q==}
-    engines: {node: '>=18'}
+  '@playwright/test@1.41.2':
+    resolution: {integrity: sha512-qQB9h7KbibJzrDpkXkYvsmiDJK14FULCCZgEcoe2AvFAS64oCirWTwzTlAYEbKaRxWs5TFesE1Na6izMv3HfGg==}
+    engines: {node: '>=16'}
+    deprecated: Please update to the latest version of Playwright to test up-to-date browsers.
     hasBin: true
 
   '@polka/url@1.0.0-next.11':
@@ -13351,26 +13352,26 @@ packages:
     engines: {node: '>=18'}
     hasBin: true
 
+  playwright-core@1.41.2:
+    resolution: {integrity: sha512-VaTvwCA4Y8kxEe+kfm2+uUUw5Lubf38RxF7FpBxLPmGe5sdNkSg5e3ChEigaGrX7qdqT3pt2m/98LiyvU2x6CA==}
+    engines: {node: '>=16'}
+    hasBin: true
+
   playwright-core@1.48.0:
     resolution: {integrity: sha512-RBvzjM9rdpP7UUFrQzRwR8L/xR4HyC1QXMzGYTbf1vjw25/ya9NRAVnXi/0fvFopjebvyPzsmoK58xxeEOaVvA==}
     engines: {node: '>=18'}
     hasBin: true
 
-  playwright-core@1.51.1:
-    resolution: {integrity: sha512-/crRMj8+j/Nq5s8QcvegseuyeZPxpQCZb6HNk3Sos3BlZyAknRjoyJPFWkpNn8v0+P3WiwqFF8P+zQo4eqiNuw==}
-    engines: {node: '>=18'}
+  playwright@1.41.2:
+    resolution: {integrity: sha512-v0bOa6H2GJChDL8pAeLa/LZC4feoAMbSQm1/jF/ySsWWoaNItvrMP7GEkvEEFyCTUYKMxjQKaTSg5up7nR6/8A==}
+    engines: {node: '>=16'}
     hasBin: true
 
   playwright@1.48.0:
     resolution: {integrity: sha512-qPqFaMEHuY/ug8o0uteYJSRfMGFikhUysk8ZvAtfKmUK3kc/6oNl/y3EczF8OFGYIi/Ex2HspMfzYArk6+XQSA==}
     engines: {node: '>=18'}
     hasBin: true
 
-  playwright@1.51.1:
-    resolution: {integrity: sha512-kkx+MB2KQRkyxjYPc3a0wLZZoDczmppyGJIvQ43l+aZihkaVvmu/21kiyaHeHjiFxjxNNFnUncKmcGIyOojsaw==}
-    engines: {node: '>=18'}
-    hasBin: true
-
   pluralize@8.0.0:
     resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
     engines: {node: '>=4'}
@@ -21467,9 +21468,9 @@ snapshots:
 
   '@pkgr/core@0.1.1': {}
 
-  '@playwright/test@1.51.1':
+  '@playwright/test@1.41.2':
     dependencies:
-      playwright: 1.51.1
+      playwright: 1.41.2
 
   '@polka/url@1.0.0-next.11': {}
 
@@ -23701,14 +23702,14 @@ snapshots:
       axe-core: 4.10.0
       mustache: 4.2.0
 
-  axe-playwright@2.0.3(playwright@1.51.1):
+  axe-playwright@2.0.3(playwright@1.48.0):
     dependencies:
       '@types/junit-report-builder': 3.0.2
       axe-core: 4.10.0
       axe-html-reporter: 2.2.11(axe-core@4.10.0)
       junit-report-builder: 5.1.1
       picocolors: 1.1.1
-      playwright: 1.51.1
+      playwright: 1.48.0
 
   axios@0.26.1:
     dependencies:
@@ -32075,19 +32076,19 @@ snapshots:
     dependencies:
       playwright-core: 1.48.0
 
-  playwright-core@1.48.0: {}
+  playwright-core@1.41.2: {}
 
-  playwright-core@1.51.1: {}
+  playwright-core@1.48.0: {}
 
-  playwright@1.48.0:
+  playwright@1.41.2:
     dependencies:
-      playwright-core: 1.48.0
+      playwright-core: 1.41.2
     optionalDependencies:
       fsevents: 2.3.2
 
-  playwright@1.51.1:
+  playwright@1.48.0:
     dependencies:
-      playwright-core: 1.51.1
+      playwright-core: 1.48.0
     optionalDependencies:
       fsevents: 2.3.2