@playdrop/playdrop-cli 0.14.8 → 0.14.9

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 (176) hide show
  1. package/config/client-meta.json +2 -2
  2. package/node_modules/@playdrop/config/client-meta.json +2 -2
  3. package/node_modules/@playwright/mcp/LICENSE +201 -0
  4. package/node_modules/@playwright/mcp/README.md +1592 -0
  5. package/node_modules/@playwright/mcp/cli.js +32 -0
  6. package/node_modules/@playwright/mcp/config.d.ts +239 -0
  7. package/node_modules/@playwright/mcp/index.d.ts +23 -0
  8. package/node_modules/@playwright/mcp/index.js +19 -0
  9. package/node_modules/@playwright/mcp/node_modules/playwright/LICENSE +202 -0
  10. package/node_modules/@playwright/mcp/node_modules/playwright/NOTICE +5 -0
  11. package/node_modules/@playwright/mcp/node_modules/playwright/README.md +318 -0
  12. package/node_modules/@playwright/mcp/node_modules/playwright/ThirdPartyNotices.txt +14 -0
  13. package/node_modules/@playwright/mcp/node_modules/playwright/cli.js +19 -0
  14. package/node_modules/@playwright/mcp/node_modules/playwright/index.d.ts +17 -0
  15. package/node_modules/@playwright/mcp/node_modules/playwright/index.js +17 -0
  16. package/node_modules/@playwright/mcp/node_modules/playwright/index.mjs +18 -0
  17. package/node_modules/@playwright/mcp/node_modules/playwright/jsx-runtime.js +42 -0
  18. package/node_modules/@playwright/mcp/node_modules/playwright/jsx-runtime.mjs +21 -0
  19. package/node_modules/@playwright/mcp/node_modules/playwright/lib/agents/agentParser.js +89 -0
  20. package/node_modules/@playwright/mcp/node_modules/playwright/lib/agents/copilot-setup-steps.yml +34 -0
  21. package/node_modules/@playwright/mcp/node_modules/playwright/lib/agents/generateAgents.js +395 -0
  22. package/node_modules/@playwright/mcp/node_modules/playwright/lib/agents/playwright-test-coverage.prompt.md +31 -0
  23. package/node_modules/@playwright/mcp/node_modules/playwright/lib/agents/playwright-test-generate.prompt.md +8 -0
  24. package/node_modules/@playwright/mcp/node_modules/playwright/lib/agents/playwright-test-generator.agent.md +88 -0
  25. package/node_modules/@playwright/mcp/node_modules/playwright/lib/agents/playwright-test-heal.prompt.md +6 -0
  26. package/node_modules/@playwright/mcp/node_modules/playwright/lib/agents/playwright-test-healer.agent.md +56 -0
  27. package/node_modules/@playwright/mcp/node_modules/playwright/lib/agents/playwright-test-plan.prompt.md +9 -0
  28. package/node_modules/@playwright/mcp/node_modules/playwright/lib/agents/playwright-test-planner.agent.md +74 -0
  29. package/node_modules/@playwright/mcp/node_modules/playwright/lib/cli/reportActions.js +78 -0
  30. package/node_modules/@playwright/mcp/node_modules/playwright/lib/cli/testActions.js +213 -0
  31. package/node_modules/@playwright/mcp/node_modules/playwright/lib/common/index.js +2966 -0
  32. package/node_modules/@playwright/mcp/node_modules/playwright/lib/common/index.js.txt +34 -0
  33. package/node_modules/@playwright/mcp/node_modules/playwright/lib/errorContext.js +129 -0
  34. package/node_modules/@playwright/mcp/node_modules/playwright/lib/globals.js +58 -0
  35. package/node_modules/@playwright/mcp/node_modules/playwright/lib/index.js +783 -0
  36. package/node_modules/@playwright/mcp/node_modules/playwright/lib/isomorphic.js +260 -0
  37. package/node_modules/@playwright/mcp/node_modules/playwright/lib/isomorphic.js.txt +9 -0
  38. package/node_modules/@playwright/mcp/node_modules/playwright/lib/loader/loaderProcessEntry.js +34 -0
  39. package/node_modules/@playwright/mcp/node_modules/playwright/lib/loader/loaderProcessEntry.js.txt +9 -0
  40. package/node_modules/@playwright/mcp/node_modules/playwright/lib/matchers/expect.js +13480 -0
  41. package/node_modules/@playwright/mcp/node_modules/playwright/lib/matchers/expect.js.LICENSE +640 -0
  42. package/node_modules/@playwright/mcp/node_modules/playwright/lib/matchers/expect.js.txt +67 -0
  43. package/node_modules/@playwright/mcp/node_modules/playwright/lib/mcp/test/browserBackend.js +125 -0
  44. package/node_modules/@playwright/mcp/node_modules/playwright/lib/mcp/test/generatorTools.js +122 -0
  45. package/node_modules/@playwright/mcp/node_modules/playwright/lib/mcp/test/plannerTools.js +150 -0
  46. package/node_modules/@playwright/mcp/node_modules/playwright/lib/mcp/test/seed.js +82 -0
  47. package/node_modules/@playwright/mcp/node_modules/playwright/lib/mcp/test/streams.js +44 -0
  48. package/node_modules/@playwright/mcp/node_modules/playwright/lib/mcp/test/testBackend.js +99 -0
  49. package/node_modules/@playwright/mcp/node_modules/playwright/lib/mcp/test/testContext.js +306 -0
  50. package/node_modules/@playwright/mcp/node_modules/playwright/lib/mcp/test/testTool.js +30 -0
  51. package/node_modules/@playwright/mcp/node_modules/playwright/lib/mcp/test/testTools.js +98 -0
  52. package/node_modules/@playwright/mcp/node_modules/playwright/lib/package.js +47 -0
  53. package/node_modules/@playwright/mcp/node_modules/playwright/lib/program.js +237 -0
  54. package/node_modules/@playwright/mcp/node_modules/playwright/lib/runner/index.js +8154 -0
  55. package/node_modules/@playwright/mcp/node_modules/playwright/lib/runner/index.js.txt +59 -0
  56. package/node_modules/@playwright/mcp/node_modules/playwright/lib/transform/babelBundle.js +72275 -0
  57. package/node_modules/@playwright/mcp/node_modules/playwright/lib/transform/babelBundle.js.LICENSE +2384 -0
  58. package/node_modules/@playwright/mcp/node_modules/playwright/lib/transform/babelBundle.js.txt +325 -0
  59. package/node_modules/@playwright/mcp/node_modules/playwright/lib/transform/esmLoader.js +8060 -0
  60. package/node_modules/@playwright/mcp/node_modules/playwright/lib/transform/esmLoader.js.LICENSE +355 -0
  61. package/node_modules/@playwright/mcp/node_modules/playwright/lib/transform/esmLoader.js.txt +60 -0
  62. package/node_modules/@playwright/mcp/node_modules/playwright/lib/util.js +373 -0
  63. package/node_modules/@playwright/mcp/node_modules/playwright/lib/worker/workerProcessEntry.js +1850 -0
  64. package/node_modules/@playwright/mcp/node_modules/playwright/lib/worker/workerProcessEntry.js.txt +19 -0
  65. package/node_modules/@playwright/mcp/node_modules/playwright/package.json +58 -0
  66. package/node_modules/@playwright/mcp/node_modules/playwright/test.d.ts +18 -0
  67. package/node_modules/@playwright/mcp/node_modules/playwright/test.js +24 -0
  68. package/node_modules/@playwright/mcp/node_modules/playwright/test.mjs +35 -0
  69. package/node_modules/@playwright/mcp/node_modules/playwright/types/test.d.ts +10709 -0
  70. package/node_modules/@playwright/mcp/node_modules/playwright/types/testReporter.d.ts +908 -0
  71. package/node_modules/@playwright/mcp/node_modules/playwright-core/LICENSE +202 -0
  72. package/node_modules/@playwright/mcp/node_modules/playwright-core/NOTICE +5 -0
  73. package/node_modules/@playwright/mcp/node_modules/playwright-core/README.md +3 -0
  74. package/node_modules/@playwright/mcp/node_modules/playwright-core/ThirdPartyNotices.txt +13 -0
  75. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/install_media_pack.ps1 +5 -0
  76. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +33 -0
  77. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +42 -0
  78. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +13 -0
  79. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +24 -0
  80. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +42 -0
  81. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +12 -0
  82. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +24 -0
  83. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +48 -0
  84. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +11 -0
  85. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +23 -0
  86. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +48 -0
  87. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +11 -0
  88. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +23 -0
  89. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +48 -0
  90. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +11 -0
  91. package/node_modules/@playwright/mcp/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +24 -0
  92. package/node_modules/@playwright/mcp/node_modules/playwright-core/browsers.json +81 -0
  93. package/node_modules/@playwright/mcp/node_modules/playwright-core/cli.js +21 -0
  94. package/node_modules/@playwright/mcp/node_modules/playwright-core/index.d.ts +17 -0
  95. package/node_modules/@playwright/mcp/node_modules/playwright-core/index.js +17 -0
  96. package/node_modules/@playwright/mcp/node_modules/playwright-core/index.mjs +28 -0
  97. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/bootstrap.js +88 -0
  98. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/coreBundle.js +74495 -0
  99. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/entry/cliDaemon.js +5 -0
  100. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/entry/dashboardApp.js +3 -0
  101. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/entry/mcp.js +10 -0
  102. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +3 -0
  103. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/package.js +50 -0
  104. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
  105. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/server/electron/loader.js +118 -0
  106. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/serverRegistry.js +7347 -0
  107. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +354 -0
  108. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +141 -0
  109. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/cli.js +6 -0
  110. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/help.json +707 -0
  111. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/minimist.js +128 -0
  112. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/output.js +343 -0
  113. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/program.js +404 -0
  114. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/registry.js +176 -0
  115. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/session.js +258 -0
  116. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/skill/SKILL.md +420 -0
  117. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/skill/references/element-attributes.md +23 -0
  118. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/skill/references/playwright-tests.md +39 -0
  119. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/skill/references/request-mocking.md +87 -0
  120. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/skill/references/running-code.md +241 -0
  121. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/skill/references/session-management.md +225 -0
  122. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/skill/references/storage-state.md +275 -0
  123. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/skill/references/test-generation.md +433 -0
  124. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/skill/references/tracing.md +139 -0
  125. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/cli-client/skill/references/video-recording.md +143 -0
  126. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
  127. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/trace/SKILL.md +171 -0
  128. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/utils/extension.js +78 -0
  129. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/tools/utils/socketConnection.js +108 -0
  130. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/utilsBundle.js +90764 -0
  131. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +2179 -0
  132. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  133. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
  134. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
  135. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
  136. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/dashboard/assets/index-CyWAfh-p.js +11 -0
  137. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/dashboard/assets/index-DhC616m4.css +1 -0
  138. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
  139. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/dashboard/index.html +29 -0
  140. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +24 -0
  141. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/htmlReport/index.html +16 -0
  142. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/htmlReport/report.css +2 -0
  143. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/htmlReport/report.js +32 -0
  144. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
  145. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-BVGIAA-i.js +32 -0
  146. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  147. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/recorder/assets/index-BQ57a3QC.js +129 -0
  148. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/recorder/assets/index-l_lX622x.css +1 -0
  149. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/recorder/index.html +29 -0
  150. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +9 -0
  151. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BSEO6m_i.js +32 -0
  152. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-CT5oRh4X.js +181 -0
  153. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
  154. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-BN2nOuEV.js +7 -0
  155. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
  156. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  157. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.BLFoOugd.css +1 -0
  158. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
  159. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/index.DLSGjmWZ.js +1 -0
  160. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/index.html +44 -0
  161. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +16 -0
  162. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +9 -0
  163. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
  164. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +10 -0
  165. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +4 -0
  166. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/uiMode.C7UW1sC9.css +1 -0
  167. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CZvydVOh.js +5 -0
  168. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +18 -0
  169. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
  170. package/node_modules/@playwright/mcp/node_modules/playwright-core/lib/xdg-open +1267 -0
  171. package/node_modules/@playwright/mcp/node_modules/playwright-core/package.json +34 -0
  172. package/node_modules/@playwright/mcp/node_modules/playwright-core/types/protocol.d.ts +24842 -0
  173. package/node_modules/@playwright/mcp/node_modules/playwright-core/types/structs.d.ts +45 -0
  174. package/node_modules/@playwright/mcp/node_modules/playwright-core/types/types.d.ts +26088 -0
  175. package/node_modules/@playwright/mcp/package.json +51 -0
  176. package/package.json +3 -1
@@ -0,0 +1,783 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
+ _baseTest: () => _baseTest,
32
+ _utilityTest: () => _utilityTest,
33
+ defineConfig: () => import_common2.defineConfig,
34
+ expect: () => import_expect.expect,
35
+ mergeExpects: () => import_expect2.mergeExpects,
36
+ mergeTests: () => import_common2.mergeTests,
37
+ test: () => test
38
+ });
39
+ module.exports = __toCommonJS(index_exports);
40
+ var import_fs = __toESM(require("fs"));
41
+ var import_path = __toESM(require("path"));
42
+ var playwrightLibrary = __toESM(require("playwright-core"));
43
+ var import_errorContext = require("./errorContext");
44
+ var import_common = require("./common");
45
+ var globals = __toESM(require("./globals"));
46
+ var import_browserBackend = require("./mcp/test/browserBackend");
47
+ var import_expect = require("./matchers/expect");
48
+ var import_common2 = require("./common");
49
+ var import_expect2 = require("./matchers/expect");
50
+ const { asLocatorDescription } = require("playwright-core/lib/coreBundle").iso;
51
+ const { getActionGroup, renderTitleForCall } = require("playwright-core/lib/coreBundle").iso;
52
+ const { escapeHTML } = require("playwright-core/lib/coreBundle").iso;
53
+ const { jsonStringifyForceASCII } = require("playwright-core/lib/coreBundle").utils;
54
+ const { createGuid } = require("playwright-core/lib/coreBundle").utils;
55
+ const { debugMode } = require("playwright-core/lib/coreBundle").utils;
56
+ const { debugLogger } = require("playwright-core/lib/coreBundle").utils;
57
+ const { currentZone } = require("playwright-core/lib/coreBundle").utils;
58
+ const _baseTest = import_common.testType.rootTestType.test;
59
+ if (process["__pw_initiator__"]) {
60
+ const originalStackTraceLimit = Error.stackTraceLimit;
61
+ Error.stackTraceLimit = 200;
62
+ try {
63
+ throw new Error("Requiring @playwright/test second time, \nFirst:\n" + process["__pw_initiator__"] + "\n\nSecond: ");
64
+ } finally {
65
+ Error.stackTraceLimit = originalStackTraceLimit;
66
+ }
67
+ } else {
68
+ process["__pw_initiator__"] = new Error().stack;
69
+ }
70
+ const utilityFixtures = {
71
+ playwright: [async ({}, use) => {
72
+ await use(require("playwright-core"));
73
+ }, { scope: "worker", box: true }],
74
+ screenshot: ["off", { scope: "worker", option: true, box: true }],
75
+ trace: ["off", { scope: "worker", option: true, box: true }],
76
+ testIdAttribute: ["data-testid", { option: true, box: true }],
77
+ _combinedContextOptions: [{}, { box: true }],
78
+ _setupArtifacts: [async ({ playwright, screenshot, _combinedContextOptions }, use, testInfo) => {
79
+ testInfo.setTimeout(testInfo.project.timeout);
80
+ const artifactsRecorder = new ArtifactsRecorder(playwright, tracing().artifactsDir(), screenshot);
81
+ await artifactsRecorder.willStartTest(testInfo);
82
+ const tracingGroupSteps = [];
83
+ const pausedContexts = /* @__PURE__ */ new Set();
84
+ const csiListener = {
85
+ onApiCallBegin: (data, channel) => {
86
+ const testInfo2 = globals.currentTestInfo();
87
+ if (!testInfo2 || data.apiName.includes("setTestIdAttribute") || data.apiName === "tracing.groupEnd")
88
+ return;
89
+ const zone = currentZone().data("stepZone");
90
+ const isExpectCall = data.apiName === "locator._expect" || data.apiName === "frame._expect" || data.apiName === "page._expectScreenshot";
91
+ if (zone && zone.category === "expect" && isExpectCall) {
92
+ if (zone.apiName)
93
+ data.apiName = zone.apiName;
94
+ if (zone.shortTitle || zone.title)
95
+ data.title = zone.shortTitle ?? zone.title;
96
+ data.stepId = zone.stepId;
97
+ return;
98
+ }
99
+ const step = testInfo2._addStep({
100
+ location: data.frames[0],
101
+ category: "pw:api",
102
+ title: renderTitle(channel.type, channel.method, channel.params, data.title),
103
+ apiName: data.apiName,
104
+ params: channel.params,
105
+ group: getActionGroup({ type: channel.type, method: channel.method })
106
+ }, tracingGroupSteps[tracingGroupSteps.length - 1]);
107
+ data.userData = step;
108
+ data.stepId = step.stepId;
109
+ if (data.apiName === "tracing.group")
110
+ tracingGroupSteps.push(step);
111
+ },
112
+ onApiCallEnd: (data) => {
113
+ if (data.apiName === "tracing.group")
114
+ return;
115
+ if (data.apiName === "tracing.groupEnd") {
116
+ const step2 = tracingGroupSteps.pop();
117
+ step2?.complete({ error: data.error });
118
+ return;
119
+ }
120
+ const step = data.userData;
121
+ step?.complete({ error: data.error });
122
+ },
123
+ onWillPause: ({ keepTestTimeout }) => {
124
+ if (!keepTestTimeout)
125
+ globals.currentTestInfo()?._setIgnoreTimeouts(true);
126
+ },
127
+ runBeforeCreateBrowserContext: async (options) => {
128
+ for (const [key, value] of Object.entries(_combinedContextOptions)) {
129
+ if (!(key in options))
130
+ options[key] = value;
131
+ }
132
+ },
133
+ runBeforeCreateRequestContext: async (options) => {
134
+ for (const [key, value] of Object.entries(_combinedContextOptions)) {
135
+ if (!(key in options))
136
+ options[key] = value;
137
+ }
138
+ },
139
+ runAfterCreateBrowserContext: async (context) => {
140
+ context.debugger.on("pausedstatechanged", () => {
141
+ const paused = !!context.debugger.pausedDetails();
142
+ if (pausedContexts.has(context) && !paused) {
143
+ pausedContexts.delete(context);
144
+ testInfo._setIgnoreTimeouts(false);
145
+ } else if (!pausedContexts.has(context) && paused) {
146
+ pausedContexts.add(context);
147
+ testInfo._setIgnoreTimeouts(true);
148
+ }
149
+ });
150
+ await artifactsRecorder.didCreateBrowserContext(context);
151
+ const currentTestInfo = globals.currentTestInfo();
152
+ if (currentTestInfo) {
153
+ attachConnectedHeaderIfNeeded(currentTestInfo, context.browser());
154
+ currentTestInfo._onCustomMessageCallback = (0, import_browserBackend.createCustomMessageHandler)(currentTestInfo, context);
155
+ await (0, import_browserBackend.runDaemonForContext)(currentTestInfo, context);
156
+ }
157
+ },
158
+ runAfterCreateRequestContext: async (context) => {
159
+ await artifactsRecorder.didCreateRequestContext(context);
160
+ },
161
+ runBeforeCloseBrowserContext: async (context) => {
162
+ await artifactsRecorder.willCloseBrowserContext(context);
163
+ },
164
+ runBeforeCloseRequestContext: async (context) => {
165
+ await artifactsRecorder.willCloseRequestContext(context);
166
+ }
167
+ };
168
+ const clientInstrumentation = playwright._instrumentation;
169
+ clientInstrumentation.addListener(csiListener);
170
+ await use();
171
+ clientInstrumentation.removeListener(csiListener);
172
+ await artifactsRecorder.didFinishTest();
173
+ }, { auto: "all-hooks-included", title: "trace recording", box: true, timeout: 0 }],
174
+ request: async ({ playwright }, use) => {
175
+ const request = await playwright.request.newContext();
176
+ await use(request);
177
+ const hook = test.info()._currentHookType();
178
+ if (hook === "beforeAll") {
179
+ await request.dispose({ reason: [
180
+ `Fixture { request } from beforeAll cannot be reused in a test.`,
181
+ ` - Recommended fix: use a separate { request } in the test.`,
182
+ ` - Alternatively, manually create APIRequestContext in beforeAll and dispose it in afterAll.`,
183
+ `See https://playwright.dev/docs/api-testing#sending-api-requests-from-ui-tests for more details.`
184
+ ].join("\n") });
185
+ } else {
186
+ await request.dispose();
187
+ }
188
+ }
189
+ };
190
+ const _utilityTest = _baseTest.extend(utilityFixtures);
191
+ const playwrightFixtures = {
192
+ defaultBrowserType: ["chromium", { scope: "worker", option: true, box: true }],
193
+ browserName: [({ defaultBrowserType }, use) => use(defaultBrowserType), { scope: "worker", option: true, box: true }],
194
+ headless: [({ launchOptions }, use) => use(launchOptions.headless ?? true), { scope: "worker", option: true, box: true }],
195
+ channel: [({ launchOptions }, use) => use(launchOptions.channel), { scope: "worker", option: true, box: true }],
196
+ launchOptions: [{}, { scope: "worker", option: true, box: true }],
197
+ connectOptions: [async ({ _optionConnectOptions }, use) => {
198
+ await use(connectOptionsFromEnv() || _optionConnectOptions);
199
+ }, { scope: "worker", option: true, box: true }],
200
+ video: ["off", { scope: "worker", option: true, box: true }],
201
+ _browserOptions: [async ({ playwright, headless, channel, launchOptions }, use) => {
202
+ const options = {
203
+ handleSIGINT: false,
204
+ ...launchOptions,
205
+ tracesDir: tracing().tracesDir(),
206
+ artifactsDir: tracing().artifactsDir()
207
+ };
208
+ if (headless !== void 0)
209
+ options.headless = headless;
210
+ if (channel !== void 0)
211
+ options.channel = channel;
212
+ playwright._defaultLaunchOptions = options;
213
+ await use(options);
214
+ playwright._defaultLaunchOptions = void 0;
215
+ }, { scope: "worker", auto: true, box: true }],
216
+ browser: [async ({ playwright, browserName, _browserOptions, connectOptions }, use, workerInfo) => {
217
+ if (!["chromium", "firefox", "webkit"].includes(browserName))
218
+ throw new Error(`Unexpected browserName "${browserName}", must be one of "chromium", "firefox" or "webkit"`);
219
+ if (connectOptions) {
220
+ const browser2 = await playwright[browserName].connect(connectOptions.wsEndpoint, {
221
+ ...connectOptions,
222
+ exposeNetwork: connectOptions.exposeNetwork,
223
+ headers: {
224
+ // HTTP headers are ASCII only (not UTF-8).
225
+ "x-playwright-launch-options": jsonStringifyForceASCII(_browserOptions),
226
+ ...connectOptions.headers
227
+ }
228
+ });
229
+ await use(browser2);
230
+ await browser2.close({ reason: "Test ended." });
231
+ return;
232
+ }
233
+ const browser = await playwright[browserName].launch();
234
+ if (process.env.PLAYWRIGHT_DASHBOARD)
235
+ await browser.bind(`worker-${workerInfo.parallelIndex}`);
236
+ await use(browser);
237
+ await browser.close({ reason: "Test ended." });
238
+ }, { scope: "worker", timeout: 0 }],
239
+ acceptDownloads: [({ contextOptions }, use) => use(contextOptions.acceptDownloads ?? true), { option: true, box: true }],
240
+ bypassCSP: [({ contextOptions }, use) => use(contextOptions.bypassCSP ?? false), { option: true, box: true }],
241
+ colorScheme: [({ contextOptions }, use) => use(contextOptions.colorScheme === void 0 ? "light" : contextOptions.colorScheme), { option: true, box: true }],
242
+ deviceScaleFactor: [({ contextOptions }, use) => use(contextOptions.deviceScaleFactor), { option: true, box: true }],
243
+ extraHTTPHeaders: [({ contextOptions }, use) => use(contextOptions.extraHTTPHeaders), { option: true, box: true }],
244
+ geolocation: [({ contextOptions }, use) => use(contextOptions.geolocation), { option: true, box: true }],
245
+ hasTouch: [({ contextOptions }, use) => use(contextOptions.hasTouch ?? false), { option: true, box: true }],
246
+ httpCredentials: [({ contextOptions }, use) => use(contextOptions.httpCredentials), { option: true, box: true }],
247
+ ignoreHTTPSErrors: [({ contextOptions }, use) => use(contextOptions.ignoreHTTPSErrors ?? false), { option: true, box: true }],
248
+ isMobile: [({ contextOptions }, use) => use(contextOptions.isMobile ?? false), { option: true, box: true }],
249
+ javaScriptEnabled: [({ contextOptions }, use) => use(contextOptions.javaScriptEnabled ?? true), { option: true, box: true }],
250
+ locale: [({ contextOptions }, use) => use(contextOptions.locale ?? "en-US"), { option: true, box: true }],
251
+ offline: [({ contextOptions }, use) => use(contextOptions.offline ?? false), { option: true, box: true }],
252
+ permissions: [({ contextOptions }, use) => use(contextOptions.permissions), { option: true, box: true }],
253
+ proxy: [({ contextOptions }, use) => use(contextOptions.proxy), { option: true, box: true }],
254
+ storageState: [({ contextOptions }, use) => use(contextOptions.storageState), { option: true, box: true }],
255
+ clientCertificates: [({ contextOptions }, use) => use(contextOptions.clientCertificates), { option: true, box: true }],
256
+ timezoneId: [({ contextOptions }, use) => use(contextOptions.timezoneId), { option: true, box: true }],
257
+ userAgent: [({ contextOptions }, use) => use(contextOptions.userAgent), { option: true, box: true }],
258
+ viewport: [({ contextOptions }, use) => use(contextOptions.viewport === void 0 ? { width: 1280, height: 720 } : contextOptions.viewport), { option: true, box: true }],
259
+ actionTimeout: [0, { option: true, box: true }],
260
+ navigationTimeout: [0, { option: true, box: true }],
261
+ baseURL: [async ({}, use) => {
262
+ await use(process.env.PLAYWRIGHT_TEST_BASE_URL);
263
+ }, { option: true, box: true }],
264
+ serviceWorkers: [({ contextOptions }, use) => use(contextOptions.serviceWorkers ?? "allow"), { option: true, box: true }],
265
+ contextOptions: [{}, { option: true, box: true }],
266
+ _combinedContextOptions: [async ({
267
+ acceptDownloads,
268
+ bypassCSP,
269
+ clientCertificates,
270
+ colorScheme,
271
+ deviceScaleFactor,
272
+ extraHTTPHeaders,
273
+ hasTouch,
274
+ geolocation,
275
+ httpCredentials,
276
+ ignoreHTTPSErrors,
277
+ isMobile,
278
+ javaScriptEnabled,
279
+ locale,
280
+ offline,
281
+ permissions,
282
+ proxy,
283
+ storageState,
284
+ viewport,
285
+ timezoneId,
286
+ userAgent,
287
+ baseURL,
288
+ contextOptions,
289
+ serviceWorkers
290
+ }, use, testInfo) => {
291
+ const options = {};
292
+ if (acceptDownloads !== void 0)
293
+ options.acceptDownloads = acceptDownloads;
294
+ if (bypassCSP !== void 0)
295
+ options.bypassCSP = bypassCSP;
296
+ if (colorScheme !== void 0)
297
+ options.colorScheme = colorScheme;
298
+ if (deviceScaleFactor !== void 0)
299
+ options.deviceScaleFactor = deviceScaleFactor;
300
+ if (extraHTTPHeaders !== void 0)
301
+ options.extraHTTPHeaders = extraHTTPHeaders;
302
+ if (geolocation !== void 0)
303
+ options.geolocation = geolocation;
304
+ if (hasTouch !== void 0)
305
+ options.hasTouch = hasTouch;
306
+ if (httpCredentials !== void 0)
307
+ options.httpCredentials = httpCredentials;
308
+ if (ignoreHTTPSErrors !== void 0)
309
+ options.ignoreHTTPSErrors = ignoreHTTPSErrors;
310
+ if (isMobile !== void 0)
311
+ options.isMobile = isMobile;
312
+ if (javaScriptEnabled !== void 0)
313
+ options.javaScriptEnabled = javaScriptEnabled;
314
+ if (locale !== void 0)
315
+ options.locale = locale;
316
+ if (offline !== void 0)
317
+ options.offline = offline;
318
+ if (permissions !== void 0)
319
+ options.permissions = permissions;
320
+ if (proxy !== void 0)
321
+ options.proxy = proxy;
322
+ if (storageState !== void 0)
323
+ options.storageState = storageState;
324
+ if (clientCertificates?.length)
325
+ options.clientCertificates = resolveClientCerticates(clientCertificates);
326
+ if (timezoneId !== void 0)
327
+ options.timezoneId = timezoneId;
328
+ if (userAgent !== void 0)
329
+ options.userAgent = userAgent;
330
+ if (viewport !== void 0)
331
+ options.viewport = viewport;
332
+ if (baseURL !== void 0)
333
+ options.baseURL = baseURL;
334
+ if (serviceWorkers !== void 0)
335
+ options.serviceWorkers = serviceWorkers;
336
+ await use({
337
+ ...contextOptions,
338
+ ...options
339
+ });
340
+ }, { scope: "test", box: true }],
341
+ _setupContextOptions: [async ({ playwright, actionTimeout, navigationTimeout, testIdAttribute }, use, _testInfo) => {
342
+ const testInfo = _testInfo;
343
+ if (testIdAttribute)
344
+ playwrightLibrary.selectors.setTestIdAttribute(testIdAttribute);
345
+ testInfo.snapshotSuffix = process.platform;
346
+ testInfo._onCustomMessageCallback = () => Promise.reject(new Error("Only tests that use default Playwright context or page fixture support test_debug"));
347
+ if (debugMode() === "inspector")
348
+ testInfo._setIgnoreTimeouts(true);
349
+ playwright._defaultContextTimeout = actionTimeout || 0;
350
+ playwright._defaultContextNavigationTimeout = navigationTimeout || 0;
351
+ await use();
352
+ playwright._defaultContextTimeout = void 0;
353
+ playwright._defaultContextNavigationTimeout = void 0;
354
+ }, { auto: "all-hooks-included", title: "context configuration", box: true }],
355
+ _contextFactory: [async ({
356
+ browser,
357
+ video,
358
+ _reuseContext,
359
+ _combinedContextOptions
360
+ /** mitigate dep-via-auto lack of traceability */
361
+ }, use, testInfo) => {
362
+ const testInfoImpl = testInfo;
363
+ const videoMode = normalizeVideoMode(video);
364
+ const captureVideo = shouldCaptureVideo(videoMode, testInfo) && !_reuseContext;
365
+ const contexts = /* @__PURE__ */ new Map();
366
+ let counter = 0;
367
+ await use(async (options) => {
368
+ const hook = testInfoImpl._currentHookType();
369
+ if (hook === "beforeAll" || hook === "afterAll") {
370
+ throw new Error([
371
+ `"context" and "page" fixtures are not supported in "${hook}" since they are created on a per-test basis.`,
372
+ `If you would like to reuse a single page between tests, create context manually with browser.newContext(). See https://aka.ms/playwright/reuse-page for details.`,
373
+ `If you would like to configure your page before each test, do that in beforeEach hook instead.`
374
+ ].join("\n"));
375
+ }
376
+ const show = typeof video === "string" ? void 0 : video.show;
377
+ const videoOptions = captureVideo ? {
378
+ recordVideo: {
379
+ dir: tracing().artifactsDir(),
380
+ size: typeof video === "string" ? void 0 : video.size,
381
+ showActions: show?.actions
382
+ }
383
+ } : {};
384
+ const context = await browser.newContext({ ...videoOptions, ...options });
385
+ let closed = false;
386
+ const close = async () => {
387
+ if (closed)
388
+ return;
389
+ closed = true;
390
+ const closeReason = testInfo.status === "timedOut" ? "Test timeout of " + testInfo.timeout + "ms exceeded." : "Test ended.";
391
+ await context.close({ reason: closeReason });
392
+ const preserveVideo = captureVideo && shouldPreserveVideo(videoMode, testInfo);
393
+ if (preserveVideo) {
394
+ const { pagesWithVideo: pagesForVideo } = contexts.get(context);
395
+ const videos = pagesForVideo.map((p) => p.video()).filter((video2) => !!video2);
396
+ await Promise.all(videos.map(async (v) => {
397
+ try {
398
+ const savedPath = testInfo.outputPath(`video${counter ? "-" + counter : ""}.webm`);
399
+ ++counter;
400
+ await v.saveAs(savedPath);
401
+ testInfo.attachments.push({ name: "video", path: savedPath, contentType: "video/webm" });
402
+ } catch (e) {
403
+ }
404
+ }));
405
+ }
406
+ };
407
+ const contextData = { close, pagesWithVideo: [] };
408
+ if (captureVideo)
409
+ context.on("page", (page) => contextData.pagesWithVideo.push(page));
410
+ contexts.set(context, contextData);
411
+ return { context, close };
412
+ });
413
+ await Promise.all([...contexts.values()].map((data) => data.close()));
414
+ }, { scope: "test", title: "context", box: true }],
415
+ _optionContextReuseMode: ["none", { scope: "worker", option: true, box: true }],
416
+ _optionConnectOptions: [void 0, { scope: "worker", option: true, box: true }],
417
+ _reuseContext: [async ({ video, _optionContextReuseMode }, use) => {
418
+ let mode = _optionContextReuseMode;
419
+ if (process.env.PW_TEST_REUSE_CONTEXT)
420
+ mode = "when-possible";
421
+ const reuse = mode === "when-possible" && normalizeVideoMode(video) === "off";
422
+ await use(reuse);
423
+ }, { scope: "worker", title: "context", box: true }],
424
+ context: async ({ browser, video, _reuseContext, _contextFactory }, use, testInfoPublic) => {
425
+ const browserImpl = browser;
426
+ const testInfo = testInfoPublic;
427
+ const show = typeof video === "string" ? void 0 : video.show;
428
+ attachConnectedHeaderIfNeeded(testInfo, browserImpl);
429
+ if (!_reuseContext) {
430
+ const { context: context2, close } = await _contextFactory();
431
+ await installScreencastTitleUpdater(testInfo, context2, show?.test);
432
+ await use(context2);
433
+ await close();
434
+ return;
435
+ }
436
+ const context = await browserImpl._wrapApiCall(() => browserImpl._newContextForReuse(), { internal: true });
437
+ await installScreencastTitleUpdater(testInfo, context, show?.test);
438
+ await use(context);
439
+ const closeReason = testInfo.status === "timedOut" ? "Test timeout of " + testInfo.timeout + "ms exceeded." : "Test ended.";
440
+ await browserImpl._wrapApiCall(() => browserImpl._disconnectFromReusedContext(closeReason), { internal: true });
441
+ },
442
+ page: async ({ context, _reuseContext }, use) => {
443
+ if (!_reuseContext) {
444
+ await use(await context.newPage());
445
+ return;
446
+ }
447
+ let [page] = context.pages();
448
+ if (!page)
449
+ page = await context.newPage();
450
+ await use(page);
451
+ }
452
+ };
453
+ function normalizeVideoMode(video) {
454
+ if (!video)
455
+ return "off";
456
+ let videoMode = typeof video === "string" ? video : video.mode;
457
+ if (videoMode === "retry-with-video")
458
+ videoMode = "on-first-retry";
459
+ return videoMode;
460
+ }
461
+ function shouldCaptureVideo(videoMode, testInfo) {
462
+ return videoMode === "on" || videoMode === "retain-on-failure" || videoMode === "retain-on-failure-and-retries" || videoMode === "on-first-retry" && testInfo.retry === 1 || videoMode === "on-all-retries" && testInfo.retry > 0 || videoMode === "retain-on-first-failure" && testInfo.retry === 0;
463
+ }
464
+ function shouldPreserveVideo(videoMode, testInfo) {
465
+ const testFailed = testInfo.status !== testInfo.expectedStatus;
466
+ switch (videoMode) {
467
+ case "on":
468
+ case "on-first-retry":
469
+ case "on-all-retries":
470
+ return true;
471
+ case "retain-on-failure":
472
+ case "retain-on-first-failure":
473
+ return testFailed;
474
+ case "retain-on-failure-and-retries":
475
+ return testFailed || testInfo.retry > 0;
476
+ default:
477
+ return false;
478
+ }
479
+ }
480
+ function normalizeScreenshotMode(screenshot) {
481
+ if (!screenshot)
482
+ return "off";
483
+ return typeof screenshot === "string" ? screenshot : screenshot.mode;
484
+ }
485
+ function attachConnectedHeaderIfNeeded(testInfo, browser) {
486
+ const connectHeaders = browser?._connection.headers;
487
+ if (!connectHeaders)
488
+ return;
489
+ for (const header of connectHeaders) {
490
+ if (header.name !== "x-playwright-attachment")
491
+ continue;
492
+ const [name, value] = header.value.split("=");
493
+ if (!name || !value)
494
+ continue;
495
+ if (testInfo.attachments.some((attachment) => attachment.name === name))
496
+ continue;
497
+ testInfo.attachments.push({ name, contentType: "text/plain", body: Buffer.from(value) });
498
+ }
499
+ }
500
+ function resolveFileToConfig(file) {
501
+ const config2 = test.info().config.configFile;
502
+ if (!config2 || !file)
503
+ return file;
504
+ if (import_path.default.isAbsolute(file))
505
+ return file;
506
+ return import_path.default.resolve(import_path.default.dirname(config2), file);
507
+ }
508
+ function resolveClientCerticates(clientCertificates) {
509
+ for (const cert of clientCertificates) {
510
+ cert.certPath = resolveFileToConfig(cert.certPath);
511
+ cert.keyPath = resolveFileToConfig(cert.keyPath);
512
+ cert.pfxPath = resolveFileToConfig(cert.pfxPath);
513
+ }
514
+ return clientCertificates;
515
+ }
516
+ const kTracingStarted = /* @__PURE__ */ Symbol("kTracingStarted");
517
+ function connectOptionsFromEnv() {
518
+ const wsEndpoint = process.env.PW_TEST_CONNECT_WS_ENDPOINT;
519
+ if (!wsEndpoint)
520
+ return void 0;
521
+ const headers = process.env.PW_TEST_CONNECT_HEADERS ? JSON.parse(process.env.PW_TEST_CONNECT_HEADERS) : void 0;
522
+ return {
523
+ wsEndpoint,
524
+ headers,
525
+ exposeNetwork: process.env.PW_TEST_CONNECT_EXPOSE_NETWORK
526
+ };
527
+ }
528
+ class SnapshotRecorder {
529
+ constructor(_artifactsRecorder, _mode, _name, _contentType, _extension, _doSnapshot) {
530
+ this._artifactsRecorder = _artifactsRecorder;
531
+ this._mode = _mode;
532
+ this._name = _name;
533
+ this._contentType = _contentType;
534
+ this._extension = _extension;
535
+ this._doSnapshot = _doSnapshot;
536
+ this._ordinal = 0;
537
+ this._temporary = [];
538
+ }
539
+ fixOrdinal() {
540
+ this._ordinal = this.testInfo.attachments.filter((a) => a.name === this._name).length;
541
+ }
542
+ shouldCaptureUponFinish() {
543
+ return this._mode === "on" || this._mode === "only-on-failure" && this.testInfo._isFailure() || this._mode === "on-first-failure" && this.testInfo._isFailure() && this.testInfo.retry === 0;
544
+ }
545
+ async maybeCapture() {
546
+ if (!this.shouldCaptureUponFinish())
547
+ return;
548
+ await Promise.all(this._artifactsRecorder._playwright._allPages().map((page) => this._snapshotPage(page, false)));
549
+ }
550
+ async persistTemporary() {
551
+ if (this.shouldCaptureUponFinish()) {
552
+ await Promise.all(this._temporary.map(async (file) => {
553
+ try {
554
+ const path2 = this._createAttachmentPath();
555
+ await import_fs.default.promises.rename(file, path2);
556
+ this._attach(path2);
557
+ } catch {
558
+ }
559
+ }));
560
+ }
561
+ }
562
+ async captureTemporary(context) {
563
+ if (this._mode === "on" || this._mode === "only-on-failure" || this._mode === "on-first-failure" && this.testInfo.retry === 0)
564
+ await Promise.all(context.pages().map((page) => this._snapshotPage(page, true)));
565
+ }
566
+ _attach(screenshotPath) {
567
+ this.testInfo.attachments.push({ name: this._name, path: screenshotPath, contentType: this._contentType });
568
+ }
569
+ _createAttachmentPath() {
570
+ const testFailed = this.testInfo._isFailure();
571
+ const index = this._ordinal + 1;
572
+ ++this._ordinal;
573
+ const path2 = this.testInfo.outputPath(`test-${testFailed ? "failed" : "finished"}-${index}${this._extension}`);
574
+ return path2;
575
+ }
576
+ _createTemporaryArtifact(...name) {
577
+ const file = import_path.default.join(this._artifactsRecorder._artifactsDir, ...name);
578
+ return file;
579
+ }
580
+ async _snapshotPage(page, temporary) {
581
+ if (page[this.testInfo._uniqueSymbol])
582
+ return;
583
+ page[this.testInfo._uniqueSymbol] = true;
584
+ try {
585
+ const path2 = temporary ? this._createTemporaryArtifact(createGuid() + this._extension) : this._createAttachmentPath();
586
+ await this._doSnapshot(page, path2);
587
+ if (temporary)
588
+ this._temporary.push(path2);
589
+ else
590
+ this._attach(path2);
591
+ } catch {
592
+ }
593
+ }
594
+ get testInfo() {
595
+ return this._artifactsRecorder._testInfo;
596
+ }
597
+ }
598
+ class ArtifactsRecorder {
599
+ constructor(playwright, artifactsDir, screenshot) {
600
+ this._playwright = playwright;
601
+ this._artifactsDir = artifactsDir;
602
+ const screenshotOptions = typeof screenshot === "string" ? void 0 : screenshot;
603
+ this._startedCollectingArtifacts = /* @__PURE__ */ Symbol("startedCollectingArtifacts");
604
+ this._screenshotRecorder = new SnapshotRecorder(this, normalizeScreenshotMode(screenshot), "screenshot", "image/png", ".png", async (page, path2) => {
605
+ await page._wrapApiCall(async () => {
606
+ await page.screenshot({ ...screenshotOptions, timeout: 5e3, path: path2, caret: "initial" });
607
+ }, { internal: true });
608
+ });
609
+ }
610
+ async willStartTest(testInfo) {
611
+ this._testInfo = testInfo;
612
+ testInfo._onDidFinishTestFunctionCallbacks.add(() => this.didFinishTestFunction());
613
+ this._screenshotRecorder.fixOrdinal();
614
+ await Promise.all(this._playwright._allContexts().map((context) => this.didCreateBrowserContext(context)));
615
+ const existingApiRequests = Array.from(this._playwright.request._contexts);
616
+ await Promise.all(existingApiRequests.map((c) => this.didCreateRequestContext(c)));
617
+ }
618
+ async didCreateBrowserContext(context) {
619
+ await this._startTraceChunkOnContextCreation(context, context.tracing);
620
+ }
621
+ async willCloseBrowserContext(context) {
622
+ await this._stopTracing(context, context.tracing);
623
+ await this._screenshotRecorder.captureTemporary(context);
624
+ await this._takePageSnapshot(context);
625
+ }
626
+ async _takePageSnapshot(context) {
627
+ if (process.env.PLAYWRIGHT_NO_COPY_PROMPT)
628
+ return;
629
+ if (this._testInfo.errors.length === 0)
630
+ return;
631
+ if (this._testInfo.errors.some((e) => e.errorContext))
632
+ return;
633
+ if (this._pageSnapshot)
634
+ return;
635
+ const page = context.pages()[0];
636
+ if (!page)
637
+ return;
638
+ try {
639
+ await page._wrapApiCall(async () => {
640
+ this._pageSnapshot = await page.ariaSnapshot({ mode: "ai", timeout: 5e3 });
641
+ }, { internal: true });
642
+ } catch (error) {
643
+ debugLogger.log("error", `failed to capture aria snapshot: ${error}`);
644
+ }
645
+ }
646
+ async didCreateRequestContext(context) {
647
+ await this._startTraceChunkOnContextCreation(context, context.tracing);
648
+ }
649
+ async willCloseRequestContext(context) {
650
+ await this._stopTracing(context, context.tracing);
651
+ }
652
+ async didFinishTestFunction() {
653
+ await this._screenshotRecorder.maybeCapture();
654
+ }
655
+ async didFinishTest() {
656
+ await this.didFinishTestFunction();
657
+ const leftoverContexts = this._playwright._allContexts();
658
+ const leftoverApiRequests = Array.from(this._playwright.request._contexts);
659
+ await Promise.all(leftoverContexts.map(async (context2) => {
660
+ await this._stopTracing(context2, context2.tracing);
661
+ }).concat(leftoverApiRequests.map(async (context2) => {
662
+ await this._stopTracing(context2, context2.tracing);
663
+ })));
664
+ await this._screenshotRecorder.persistTemporary();
665
+ const context = leftoverContexts[0];
666
+ if (context)
667
+ await this._takePageSnapshot(context);
668
+ if (this._testInfo.errors.length > 0) {
669
+ const hasMatcherAriaSnapshot = this._testInfo.errors.some((e) => e.errorContext);
670
+ const errorContextContent = (0, import_errorContext.buildErrorContext)({
671
+ titlePath: this._testInfo.titlePath,
672
+ location: { file: this._testInfo.file, line: this._testInfo.line, column: this._testInfo.column },
673
+ errors: this._testInfo.errors,
674
+ pageSnapshot: hasMatcherAriaSnapshot ? void 0 : this._pageSnapshot
675
+ });
676
+ if (errorContextContent) {
677
+ const filePath = this._testInfo.outputPath("error-context.md");
678
+ await import_fs.default.promises.writeFile(filePath, errorContextContent, "utf8");
679
+ this._testInfo._attach({
680
+ name: "error-context",
681
+ contentType: "text/markdown",
682
+ path: filePath
683
+ }, void 0);
684
+ }
685
+ }
686
+ }
687
+ async _startTraceChunkOnContextCreation(channelOwner, tracing2) {
688
+ await channelOwner._wrapApiCall(async () => {
689
+ const options = this._testInfo._tracing.traceOptions();
690
+ if (options) {
691
+ const title = this._testInfo._tracing.traceTitle();
692
+ const name = this._testInfo._tracing.generateNextTraceRecordingName();
693
+ if (!tracing2[kTracingStarted]) {
694
+ await tracing2.start({ ...options, title, name });
695
+ tracing2[kTracingStarted] = true;
696
+ } else {
697
+ await tracing2.startChunk({ title, name });
698
+ }
699
+ } else {
700
+ if (tracing2[kTracingStarted]) {
701
+ tracing2[kTracingStarted] = false;
702
+ await tracing2.stop();
703
+ }
704
+ }
705
+ }, { internal: true });
706
+ }
707
+ async _stopTracing(channelOwner, tracing2) {
708
+ await channelOwner._wrapApiCall(async () => {
709
+ if (tracing2[this._startedCollectingArtifacts])
710
+ return;
711
+ tracing2[this._startedCollectingArtifacts] = true;
712
+ if (this._testInfo._tracing.traceOptions() && tracing2[kTracingStarted])
713
+ await tracing2.stopChunk({ path: this._testInfo._tracing.maybeGenerateNextTraceRecordingPath() });
714
+ }, { internal: true });
715
+ }
716
+ }
717
+ async function installScreencastTitleUpdater(testInfo, context, testAnnotate) {
718
+ if (!testAnnotate)
719
+ return;
720
+ const testTitle = testAnnotate.level === "file" ? [testInfo.titlePath[0]] : testInfo.titlePath;
721
+ const stepStack = [];
722
+ const overlays = /* @__PURE__ */ new Map();
723
+ const position = testAnnotate.position ?? "top-left";
724
+ const fontSize = testAnnotate.fontSize ?? 14;
725
+ const level = testAnnotate.level ?? "step";
726
+ const updateOverlay = async () => {
727
+ const parts = level === "step" ? [...testTitle, ...stepStack] : testTitle;
728
+ const html = createTestOverlay(parts, position, fontSize);
729
+ for (const page of context.pages()) {
730
+ await overlays.get(page)?.dispose();
731
+ overlays.delete(page);
732
+ const disposable = await page.screencast.showOverlay(html);
733
+ overlays.set(page, disposable);
734
+ }
735
+ };
736
+ testInfo._onUserStepBegin = async (title) => {
737
+ stepStack.push(title);
738
+ await updateOverlay();
739
+ };
740
+ testInfo._onUserStepEnd = async () => {
741
+ stepStack.pop();
742
+ await updateOverlay();
743
+ };
744
+ context.on("page", async () => {
745
+ void updateOverlay();
746
+ });
747
+ await updateOverlay();
748
+ }
749
+ function createTestOverlay(parts, position, fontSize) {
750
+ const positionStyles = {
751
+ "top-left": "top: 6px; left: 6px;",
752
+ "top": "top: 6px; left: 50%; transform: translateX(-50%);",
753
+ "top-right": "top: 6px; right: 6px;",
754
+ "bottom-left": "bottom: 6px; left: 6px;",
755
+ "bottom": "bottom: 6px; left: 50%; transform: translateX(-50%);",
756
+ "bottom-right": "bottom: 6px; right: 6px;"
757
+ };
758
+ const posStyle = positionStyles[position] ?? positionStyles["top-left"];
759
+ return `<div style="white-space: nowrap; font-size: ${fontSize}px; padding: 3px 6px; background: rgba(0,0,0,0.5); color: white; border-radius: 4px; position: absolute; ${posStyle}">
760
+ ${parts.map((p) => `<div>${escapeHTML(p)}</div>`).join("")}
761
+ </div>`;
762
+ }
763
+ function renderTitle(type, method, params, title) {
764
+ const prefix = renderTitleForCall({ title, type, method, params });
765
+ let selector;
766
+ if (params?.["selector"] && typeof params.selector === "string")
767
+ selector = asLocatorDescription("javascript", params.selector);
768
+ return prefix + (selector ? ` ${selector}` : "");
769
+ }
770
+ function tracing() {
771
+ return test.info()._tracing;
772
+ }
773
+ const test = _utilityTest.extend(playwrightFixtures);
774
+ // Annotate the CommonJS export names for ESM import in node:
775
+ 0 && (module.exports = {
776
+ _baseTest,
777
+ _utilityTest,
778
+ defineConfig,
779
+ expect,
780
+ mergeExpects,
781
+ mergeTests,
782
+ test
783
+ });