@stablyai/internal-playwright 0.1.0

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 (297) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +168 -0
  4. package/ThirdPartyNotices.txt +6277 -0
  5. package/cli.js +19 -0
  6. package/index.d.ts +17 -0
  7. package/index.js +17 -0
  8. package/index.mjs +18 -0
  9. package/jsx-runtime.js +42 -0
  10. package/jsx-runtime.mjs +21 -0
  11. package/lib/agents/generateAgents.js +265 -0
  12. package/lib/agents/generator.md +102 -0
  13. package/lib/agents/healer.md +78 -0
  14. package/lib/agents/planner.md +135 -0
  15. package/lib/cli.js +274 -0
  16. package/lib/common/config.js +274 -0
  17. package/lib/common/config.js.map +7 -0
  18. package/lib/common/configLoader.js +377 -0
  19. package/lib/common/configLoader.js.map +7 -0
  20. package/lib/common/esmLoaderHost.js +102 -0
  21. package/lib/common/esmLoaderHost.js.map +7 -0
  22. package/lib/common/expectBundle.js +52 -0
  23. package/lib/common/expectBundle.js.map +7 -0
  24. package/lib/common/expectBundleImpl.js +389 -0
  25. package/lib/common/expectBundleImpl.js.map +7 -0
  26. package/lib/common/fixtures.js +302 -0
  27. package/lib/common/fixtures.js.map +7 -0
  28. package/lib/common/globals.js +58 -0
  29. package/lib/common/globals.js.map +7 -0
  30. package/lib/common/ipc.js +60 -0
  31. package/lib/common/ipc.js.map +7 -0
  32. package/lib/common/poolBuilder.js +85 -0
  33. package/lib/common/poolBuilder.js.map +7 -0
  34. package/lib/common/process.js +104 -0
  35. package/lib/common/process.js.map +7 -0
  36. package/lib/common/suiteUtils.js +140 -0
  37. package/lib/common/suiteUtils.js.map +7 -0
  38. package/lib/common/test.js +321 -0
  39. package/lib/common/test.js.map +7 -0
  40. package/lib/common/testLoader.js +100 -0
  41. package/lib/common/testLoader.js.map +7 -0
  42. package/lib/common/testType.js +310 -0
  43. package/lib/common/testType.js.map +7 -0
  44. package/lib/fsWatcher.js +67 -0
  45. package/lib/fsWatcher.js.map +7 -0
  46. package/lib/index.js +696 -0
  47. package/lib/index.js.map +7 -0
  48. package/lib/internalsForTest.js +42 -0
  49. package/lib/internalsForTest.js.map +7 -0
  50. package/lib/isomorphic/events.js +77 -0
  51. package/lib/isomorphic/events.js.map +7 -0
  52. package/lib/isomorphic/folders.js +30 -0
  53. package/lib/isomorphic/folders.js.map +7 -0
  54. package/lib/isomorphic/stringInternPool.js +69 -0
  55. package/lib/isomorphic/stringInternPool.js.map +7 -0
  56. package/lib/isomorphic/teleReceiver.js +507 -0
  57. package/lib/isomorphic/teleReceiver.js.map +7 -0
  58. package/lib/isomorphic/teleSuiteUpdater.js +137 -0
  59. package/lib/isomorphic/teleSuiteUpdater.js.map +7 -0
  60. package/lib/isomorphic/testServerConnection.js +211 -0
  61. package/lib/isomorphic/testServerConnection.js.map +7 -0
  62. package/lib/isomorphic/testServerInterface.js +16 -0
  63. package/lib/isomorphic/testServerInterface.js.map +7 -0
  64. package/lib/isomorphic/testTree.js +334 -0
  65. package/lib/isomorphic/testTree.js.map +7 -0
  66. package/lib/isomorphic/types.d.js +16 -0
  67. package/lib/isomorphic/types.d.js.map +7 -0
  68. package/lib/loader/loaderMain.js +59 -0
  69. package/lib/loader/loaderMain.js.map +7 -0
  70. package/lib/matchers/expect.js +325 -0
  71. package/lib/matchers/expect.js.map +7 -0
  72. package/lib/matchers/matcherHint.js +87 -0
  73. package/lib/matchers/matcherHint.js.map +7 -0
  74. package/lib/matchers/matchers.js +366 -0
  75. package/lib/matchers/matchers.js.map +7 -0
  76. package/lib/matchers/toBeTruthy.js +73 -0
  77. package/lib/matchers/toBeTruthy.js.map +7 -0
  78. package/lib/matchers/toEqual.js +99 -0
  79. package/lib/matchers/toEqual.js.map +7 -0
  80. package/lib/matchers/toHaveURL.js +102 -0
  81. package/lib/matchers/toHaveURL.js.map +7 -0
  82. package/lib/matchers/toMatchAriaSnapshot.js +159 -0
  83. package/lib/matchers/toMatchAriaSnapshot.js.map +7 -0
  84. package/lib/matchers/toMatchSnapshot.js +359 -0
  85. package/lib/matchers/toMatchSnapshot.js.map +7 -0
  86. package/lib/matchers/toMatchText.js +99 -0
  87. package/lib/matchers/toMatchText.js.map +7 -0
  88. package/lib/mcp/browser/actions.d.js +16 -0
  89. package/lib/mcp/browser/backend.js +93 -0
  90. package/lib/mcp/browser/backend.js.map +7 -0
  91. package/lib/mcp/browser/browserContextFactory.js +296 -0
  92. package/lib/mcp/browser/browserServerBackend.js +76 -0
  93. package/lib/mcp/browser/codegen.js +66 -0
  94. package/lib/mcp/browser/config.js +385 -0
  95. package/lib/mcp/browser/context.js +287 -0
  96. package/lib/mcp/browser/response.js +228 -0
  97. package/lib/mcp/browser/sessionLog.js +160 -0
  98. package/lib/mcp/browser/tab.js +277 -0
  99. package/lib/mcp/browser/tool.js +30 -0
  100. package/lib/mcp/browser/tool.js.map +7 -0
  101. package/lib/mcp/browser/tools/common.js +63 -0
  102. package/lib/mcp/browser/tools/console.js +44 -0
  103. package/lib/mcp/browser/tools/dialogs.js +60 -0
  104. package/lib/mcp/browser/tools/evaluate.js +70 -0
  105. package/lib/mcp/browser/tools/files.js +58 -0
  106. package/lib/mcp/browser/tools/form.js +74 -0
  107. package/lib/mcp/browser/tools/install.js +69 -0
  108. package/lib/mcp/browser/tools/keyboard.js +85 -0
  109. package/lib/mcp/browser/tools/mouse.js +107 -0
  110. package/lib/mcp/browser/tools/navigate.js +62 -0
  111. package/lib/mcp/browser/tools/network.js +54 -0
  112. package/lib/mcp/browser/tools/pdf.js +59 -0
  113. package/lib/mcp/browser/tools/screenshot.js +88 -0
  114. package/lib/mcp/browser/tools/snapshot.js +182 -0
  115. package/lib/mcp/browser/tools/tabs.js +67 -0
  116. package/lib/mcp/browser/tools/tool.js +49 -0
  117. package/lib/mcp/browser/tools/tracing.js +74 -0
  118. package/lib/mcp/browser/tools/utils.js +100 -0
  119. package/lib/mcp/browser/tools/verify.js +154 -0
  120. package/lib/mcp/browser/tools/wait.js +63 -0
  121. package/lib/mcp/browser/tools.js +80 -0
  122. package/lib/mcp/browser/tools.js.map +7 -0
  123. package/lib/mcp/browser/watchdog.js +44 -0
  124. package/lib/mcp/config.d.js +16 -0
  125. package/lib/mcp/extension/cdpRelay.js +351 -0
  126. package/lib/mcp/extension/extensionContextFactory.js +75 -0
  127. package/lib/mcp/extension/protocol.js +28 -0
  128. package/lib/mcp/index.js +61 -0
  129. package/lib/mcp/log.js +35 -0
  130. package/lib/mcp/program.js +96 -0
  131. package/lib/mcp/sdk/bundle.js +81 -0
  132. package/lib/mcp/sdk/bundle.js.map +7 -0
  133. package/lib/mcp/sdk/call.js +49 -0
  134. package/lib/mcp/sdk/call.js.map +7 -0
  135. package/lib/mcp/sdk/exports.js +32 -0
  136. package/lib/mcp/sdk/exports.js.map +7 -0
  137. package/lib/mcp/sdk/http.js +187 -0
  138. package/lib/mcp/sdk/http.js.map +7 -0
  139. package/lib/mcp/sdk/inProcessTransport.js +71 -0
  140. package/lib/mcp/sdk/inProcessTransport.js.map +7 -0
  141. package/lib/mcp/sdk/mdb.js +206 -0
  142. package/lib/mcp/sdk/mdb.js.map +7 -0
  143. package/lib/mcp/sdk/proxyBackend.js +128 -0
  144. package/lib/mcp/sdk/proxyBackend.js.map +7 -0
  145. package/lib/mcp/sdk/server.js +189 -0
  146. package/lib/mcp/sdk/server.js.map +7 -0
  147. package/lib/mcp/sdk/tool.js +51 -0
  148. package/lib/mcp/sdk/tool.js.map +7 -0
  149. package/lib/mcp/test/backend.js +67 -0
  150. package/lib/mcp/test/backend.js.map +7 -0
  151. package/lib/mcp/test/browserBackend.js +98 -0
  152. package/lib/mcp/test/context.js +48 -0
  153. package/lib/mcp/test/context.js.map +7 -0
  154. package/lib/mcp/test/generatorTools.js +122 -0
  155. package/lib/mcp/test/plannerTools.js +46 -0
  156. package/lib/mcp/test/seed.js +72 -0
  157. package/lib/mcp/test/streams.js +39 -0
  158. package/lib/mcp/test/streams.js.map +7 -0
  159. package/lib/mcp/test/testBackend.js +97 -0
  160. package/lib/mcp/test/testContext.js +176 -0
  161. package/lib/mcp/test/testTool.js +30 -0
  162. package/lib/mcp/test/testTools.js +115 -0
  163. package/lib/mcp/test/tool.js +30 -0
  164. package/lib/mcp/test/tool.js.map +7 -0
  165. package/lib/mcp/test/tools.js +150 -0
  166. package/lib/mcp/test/tools.js.map +7 -0
  167. package/lib/mcp/vscode/host.js +187 -0
  168. package/lib/mcp/vscode/main.js +77 -0
  169. package/lib/mcpBundleImpl.js +41 -0
  170. package/lib/mcpBundleImpl.js.map +7 -0
  171. package/lib/plugins/gitCommitInfoPlugin.js +198 -0
  172. package/lib/plugins/gitCommitInfoPlugin.js.map +7 -0
  173. package/lib/plugins/index.js +28 -0
  174. package/lib/plugins/index.js.map +7 -0
  175. package/lib/plugins/webServerPlugin.js +209 -0
  176. package/lib/plugins/webServerPlugin.js.map +7 -0
  177. package/lib/program.js +412 -0
  178. package/lib/program.js.map +7 -0
  179. package/lib/reporters/base.js +609 -0
  180. package/lib/reporters/base.js.map +7 -0
  181. package/lib/reporters/blob.js +135 -0
  182. package/lib/reporters/blob.js.map +7 -0
  183. package/lib/reporters/dot.js +82 -0
  184. package/lib/reporters/dot.js.map +7 -0
  185. package/lib/reporters/empty.js +32 -0
  186. package/lib/reporters/empty.js.map +7 -0
  187. package/lib/reporters/github.js +128 -0
  188. package/lib/reporters/github.js.map +7 -0
  189. package/lib/reporters/html.js +644 -0
  190. package/lib/reporters/html.js.map +7 -0
  191. package/lib/reporters/internalReporter.js +130 -0
  192. package/lib/reporters/internalReporter.js.map +7 -0
  193. package/lib/reporters/json.js +254 -0
  194. package/lib/reporters/json.js.map +7 -0
  195. package/lib/reporters/junit.js +230 -0
  196. package/lib/reporters/junit.js.map +7 -0
  197. package/lib/reporters/line.js +113 -0
  198. package/lib/reporters/line.js.map +7 -0
  199. package/lib/reporters/list.js +235 -0
  200. package/lib/reporters/list.js.map +7 -0
  201. package/lib/reporters/listModeReporter.js +69 -0
  202. package/lib/reporters/listModeReporter.js.map +7 -0
  203. package/lib/reporters/markdown.js +144 -0
  204. package/lib/reporters/markdown.js.map +7 -0
  205. package/lib/reporters/merge.js +535 -0
  206. package/lib/reporters/merge.js.map +7 -0
  207. package/lib/reporters/multiplexer.js +104 -0
  208. package/lib/reporters/multiplexer.js.map +7 -0
  209. package/lib/reporters/reporterV2.js +102 -0
  210. package/lib/reporters/reporterV2.js.map +7 -0
  211. package/lib/reporters/teleEmitter.js +297 -0
  212. package/lib/reporters/teleEmitter.js.map +7 -0
  213. package/lib/reporters/versions/blobV1.js +16 -0
  214. package/lib/reporters/versions/blobV1.js.map +7 -0
  215. package/lib/runner/dispatcher.js +491 -0
  216. package/lib/runner/dispatcher.js.map +7 -0
  217. package/lib/runner/failureTracker.js +72 -0
  218. package/lib/runner/failureTracker.js.map +7 -0
  219. package/lib/runner/lastRun.js +77 -0
  220. package/lib/runner/lastRun.js.map +7 -0
  221. package/lib/runner/loadUtils.js +333 -0
  222. package/lib/runner/loadUtils.js.map +7 -0
  223. package/lib/runner/loaderHost.js +89 -0
  224. package/lib/runner/loaderHost.js.map +7 -0
  225. package/lib/runner/processHost.js +161 -0
  226. package/lib/runner/processHost.js.map +7 -0
  227. package/lib/runner/projectUtils.js +241 -0
  228. package/lib/runner/projectUtils.js.map +7 -0
  229. package/lib/runner/rebase.js +189 -0
  230. package/lib/runner/rebase.js.map +7 -0
  231. package/lib/runner/reporters.js +137 -0
  232. package/lib/runner/reporters.js.map +7 -0
  233. package/lib/runner/runner.js +173 -0
  234. package/lib/runner/sigIntWatcher.js +96 -0
  235. package/lib/runner/sigIntWatcher.js.map +7 -0
  236. package/lib/runner/taskRunner.js +127 -0
  237. package/lib/runner/taskRunner.js.map +7 -0
  238. package/lib/runner/tasks.js +410 -0
  239. package/lib/runner/tasks.js.map +7 -0
  240. package/lib/runner/testGroups.js +117 -0
  241. package/lib/runner/testGroups.js.map +7 -0
  242. package/lib/runner/testRunner.js +390 -0
  243. package/lib/runner/testRunner.js.map +7 -0
  244. package/lib/runner/testServer.js +264 -0
  245. package/lib/runner/testServer.js.map +7 -0
  246. package/lib/runner/uiMode.js +271 -0
  247. package/lib/runner/uiModeReporter.js +30 -0
  248. package/lib/runner/uiModeReporter.js.map +7 -0
  249. package/lib/runner/vcs.js +72 -0
  250. package/lib/runner/vcs.js.map +7 -0
  251. package/lib/runner/watchMode.js +395 -0
  252. package/lib/runner/watchMode.js.map +7 -0
  253. package/lib/runner/workerHost.js +95 -0
  254. package/lib/runner/workerHost.js.map +7 -0
  255. package/lib/store.js +98 -0
  256. package/lib/third_party/pirates.js +62 -0
  257. package/lib/third_party/pirates.js.map +7 -0
  258. package/lib/third_party/tsconfig-loader.js +103 -0
  259. package/lib/third_party/tsconfig-loader.js.map +7 -0
  260. package/lib/transform/babelBundle.js +43 -0
  261. package/lib/transform/babelBundle.js.map +7 -0
  262. package/lib/transform/babelBundleImpl.js +461 -0
  263. package/lib/transform/babelBundleImpl.js.map +7 -0
  264. package/lib/transform/compilationCache.js +272 -0
  265. package/lib/transform/compilationCache.js.map +7 -0
  266. package/lib/transform/esmLoader.js +104 -0
  267. package/lib/transform/esmLoader.js.map +7 -0
  268. package/lib/transform/esmUtils.js +32 -0
  269. package/lib/transform/portTransport.js +67 -0
  270. package/lib/transform/portTransport.js.map +7 -0
  271. package/lib/transform/transform.js +293 -0
  272. package/lib/transform/transform.js.map +7 -0
  273. package/lib/util.js +403 -0
  274. package/lib/util.js.map +7 -0
  275. package/lib/utilsBundle.js +43 -0
  276. package/lib/utilsBundle.js.map +7 -0
  277. package/lib/utilsBundleImpl.js +100 -0
  278. package/lib/utilsBundleImpl.js.map +7 -0
  279. package/lib/worker/fixtureRunner.js +258 -0
  280. package/lib/worker/fixtureRunner.js.map +7 -0
  281. package/lib/worker/stepContext.js +34 -0
  282. package/lib/worker/testInfo.js +508 -0
  283. package/lib/worker/testInfo.js.map +7 -0
  284. package/lib/worker/testTracing.js +344 -0
  285. package/lib/worker/testTracing.js.map +7 -0
  286. package/lib/worker/timeoutManager.js +174 -0
  287. package/lib/worker/timeoutManager.js.map +7 -0
  288. package/lib/worker/util.js +31 -0
  289. package/lib/worker/util.js.map +7 -0
  290. package/lib/worker/workerMain.js +520 -0
  291. package/lib/worker/workerMain.js.map +7 -0
  292. package/package.json +74 -0
  293. package/test.d.ts +18 -0
  294. package/test.js +24 -0
  295. package/test.mjs +33 -0
  296. package/types/test.d.ts +10217 -0
  297. package/types/testReporter.d.ts +816 -0
@@ -0,0 +1,100 @@
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 testLoader_exports = {};
30
+ __export(testLoader_exports, {
31
+ defaultTimeout: () => defaultTimeout,
32
+ loadTestFile: () => loadTestFile
33
+ });
34
+ module.exports = __toCommonJS(testLoader_exports);
35
+ var import_path = __toESM(require("path"));
36
+ var import_util = __toESM(require("util"));
37
+ var esmLoaderHost = __toESM(require("./esmLoaderHost"));
38
+ var import_globals = require("./globals");
39
+ var import_test = require("./test");
40
+ var import_compilationCache = require("../transform/compilationCache");
41
+ var import_transform = require("../transform/transform");
42
+ var import_util2 = require("../util");
43
+ const defaultTimeout = 3e4;
44
+ const cachedFileSuites = /* @__PURE__ */ new Map();
45
+ async function loadTestFile(file, rootDir, testErrors) {
46
+ if (cachedFileSuites.has(file))
47
+ return cachedFileSuites.get(file);
48
+ const suite = new import_test.Suite(import_path.default.relative(rootDir, file) || import_path.default.basename(file), "file");
49
+ suite._requireFile = file;
50
+ suite.location = { file, line: 0, column: 0 };
51
+ (0, import_globals.setCurrentlyLoadingFileSuite)(suite);
52
+ if (!(0, import_globals.isWorkerProcess)()) {
53
+ (0, import_compilationCache.startCollectingFileDeps)();
54
+ await esmLoaderHost.startCollectingFileDeps();
55
+ }
56
+ try {
57
+ await (0, import_transform.requireOrImport)(file);
58
+ cachedFileSuites.set(file, suite);
59
+ } catch (e) {
60
+ if (!testErrors)
61
+ throw e;
62
+ testErrors.push(serializeLoadError(file, e));
63
+ } finally {
64
+ (0, import_globals.setCurrentlyLoadingFileSuite)(void 0);
65
+ if (!(0, import_globals.isWorkerProcess)()) {
66
+ (0, import_compilationCache.stopCollectingFileDeps)(file);
67
+ await esmLoaderHost.stopCollectingFileDeps(file);
68
+ }
69
+ }
70
+ {
71
+ const files = /* @__PURE__ */ new Set();
72
+ suite.allTests().map((t) => files.add(t.location.file));
73
+ if (files.size === 1) {
74
+ const mappedFile = files.values().next().value;
75
+ if (suite.location.file !== mappedFile) {
76
+ if (import_path.default.extname(mappedFile) !== import_path.default.extname(suite.location.file))
77
+ suite.location.file = mappedFile;
78
+ }
79
+ }
80
+ }
81
+ return suite;
82
+ }
83
+ function serializeLoadError(file, error) {
84
+ if (error instanceof Error) {
85
+ const result = (0, import_util2.filterStackTrace)(error);
86
+ const loc = error.loc;
87
+ result.location = loc ? {
88
+ file,
89
+ line: loc.line || 0,
90
+ column: loc.column || 0
91
+ } : void 0;
92
+ return result;
93
+ }
94
+ return { value: import_util.default.inspect(error) };
95
+ }
96
+ // Annotate the CommonJS export names for ESM import in node:
97
+ 0 && (module.exports = {
98
+ defaultTimeout,
99
+ loadTestFile
100
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/common/testLoader.ts"],
4
+ "sourcesContent": ["/**\n * Copyright Microsoft Corporation. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from 'path';\nimport util from 'util';\n\nimport * as esmLoaderHost from './esmLoaderHost';\nimport { isWorkerProcess, setCurrentlyLoadingFileSuite } from './globals';\nimport { Suite } from './test';\nimport { startCollectingFileDeps, stopCollectingFileDeps } from '../transform/compilationCache';\nimport { requireOrImport } from '../transform/transform';\nimport { filterStackTrace } from '../util';\n\nimport type { TestError } from '../../types/testReporter';\n\nexport const defaultTimeout = 30000;\n\n// To allow multiple loaders in the same process without clearing require cache,\n// we make these maps global.\nconst cachedFileSuites = new Map<string, Suite>();\n\nexport async function loadTestFile(file: string, rootDir: string, testErrors?: TestError[]): Promise<Suite> {\n if (cachedFileSuites.has(file))\n return cachedFileSuites.get(file)!;\n const suite = new Suite(path.relative(rootDir, file) || path.basename(file), 'file');\n suite._requireFile = file;\n suite.location = { file, line: 0, column: 0 };\n\n setCurrentlyLoadingFileSuite(suite);\n if (!isWorkerProcess()) {\n startCollectingFileDeps();\n await esmLoaderHost.startCollectingFileDeps();\n }\n try {\n await requireOrImport(file);\n cachedFileSuites.set(file, suite);\n } catch (e) {\n if (!testErrors)\n throw e;\n testErrors.push(serializeLoadError(file, e));\n } finally {\n setCurrentlyLoadingFileSuite(undefined);\n if (!isWorkerProcess()) {\n stopCollectingFileDeps(file);\n await esmLoaderHost.stopCollectingFileDeps(file);\n }\n }\n\n {\n // Test locations that we discover potentially have different file name.\n // This could be due to either\n // a) use of source maps or due to\n // b) require of one file from another.\n // Try fixing (a) w/o regressing (b).\n\n const files = new Set<string>();\n suite.allTests().map(t => files.add(t.location.file));\n if (files.size === 1) {\n // All tests point to one file.\n const mappedFile = files.values().next().value!;\n if (suite.location.file !== mappedFile) {\n // The file is different, check for a likely source map case.\n if (path.extname(mappedFile) !== path.extname(suite.location.file))\n suite.location.file = mappedFile;\n }\n }\n }\n\n return suite;\n}\n\nfunction serializeLoadError(file: string, error: Error | any): TestError {\n if (error instanceof Error) {\n const result: TestError = filterStackTrace(error);\n // Babel parse errors have location.\n const loc = (error as any).loc;\n result.location = loc ? {\n file,\n line: loc.line || 0,\n column: loc.column || 0,\n } : undefined;\n return result;\n }\n return { value: util.inspect(error) };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,kBAAiB;AACjB,kBAAiB;AAEjB,oBAA+B;AAC/B,qBAA8D;AAC9D,kBAAsB;AACtB,8BAAgE;AAChE,uBAAgC;AAChC,IAAAA,eAAiC;AAI1B,MAAM,iBAAiB;AAI9B,MAAM,mBAAmB,oBAAI,IAAmB;AAEhD,eAAsB,aAAa,MAAc,SAAiB,YAA0C;AAC1G,MAAI,iBAAiB,IAAI,IAAI;AAC3B,WAAO,iBAAiB,IAAI,IAAI;AAClC,QAAM,QAAQ,IAAI,kBAAM,YAAAC,QAAK,SAAS,SAAS,IAAI,KAAK,YAAAA,QAAK,SAAS,IAAI,GAAG,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", "util"]
7
+ }
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var testType_exports = {};
20
+ __export(testType_exports, {
21
+ TestTypeImpl: () => TestTypeImpl,
22
+ mergeTests: () => mergeTests,
23
+ rootTestType: () => rootTestType
24
+ });
25
+ module.exports = __toCommonJS(testType_exports);
26
+ var import_playwright_core = require("playwright-core");
27
+ var import_utils = require("playwright-core/lib/utils");
28
+ var import_globals = require("./globals");
29
+ var import_test = require("./test");
30
+ var import_expect = require("../matchers/expect");
31
+ var import_transform = require("../transform/transform");
32
+ var import_stepContext = require("../worker/stepContext");
33
+ const testTypeSymbol = Symbol("testType");
34
+ class TestTypeImpl {
35
+ constructor(fixtures) {
36
+ this.fixtures = fixtures;
37
+ const test = (0, import_transform.wrapFunctionWithLocation)(this._createTest.bind(this, "default"));
38
+ test[testTypeSymbol] = this;
39
+ test.expect = import_expect.expect;
40
+ test.only = (0, import_transform.wrapFunctionWithLocation)(this._createTest.bind(this, "only"));
41
+ test.describe = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "default"));
42
+ test.describe.only = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "only"));
43
+ test.describe.configure = (0, import_transform.wrapFunctionWithLocation)(this._configure.bind(this));
44
+ test.describe.fixme = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "fixme"));
45
+ test.describe.parallel = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "parallel"));
46
+ test.describe.parallel.only = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "parallel.only"));
47
+ test.describe.serial = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "serial"));
48
+ test.describe.serial.only = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "serial.only"));
49
+ test.describe.skip = (0, import_transform.wrapFunctionWithLocation)(this._describe.bind(this, "skip"));
50
+ test.beforeEach = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "beforeEach"));
51
+ test.afterEach = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "afterEach"));
52
+ test.beforeAll = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "beforeAll"));
53
+ test.afterAll = (0, import_transform.wrapFunctionWithLocation)(this._hook.bind(this, "afterAll"));
54
+ test.skip = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "skip"));
55
+ test.fixme = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "fixme"));
56
+ test.fail = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "fail"));
57
+ test.fail.only = (0, import_transform.wrapFunctionWithLocation)(this._createTest.bind(this, "fail.only"));
58
+ test.slow = (0, import_transform.wrapFunctionWithLocation)(this._modifier.bind(this, "slow"));
59
+ test.setTimeout = (0, import_transform.wrapFunctionWithLocation)(this._setTimeout.bind(this));
60
+ test.step = this._step.bind(this, "pass");
61
+ test.step.skip = this._step.bind(this, "skip");
62
+ test.use = (0, import_transform.wrapFunctionWithLocation)(this._use.bind(this));
63
+ test.extend = (0, import_transform.wrapFunctionWithLocation)(this._extend.bind(this));
64
+ test.info = () => {
65
+ const result = (0, import_globals.currentTestInfo)();
66
+ if (!result)
67
+ throw new Error("test.info() can only be called while test is running");
68
+ return result;
69
+ };
70
+ this.test = test;
71
+ }
72
+ _currentSuite(location, title) {
73
+ const suite = (0, import_globals.currentlyLoadingFileSuite)();
74
+ if (!suite) {
75
+ throw new Error([
76
+ `Playwright Test did not expect ${title} to be called here.`,
77
+ `Most common reasons include:`,
78
+ `- You are calling ${title} in a configuration file.`,
79
+ `- You are calling ${title} in a file that is imported by the configuration file.`,
80
+ `- You have two different versions of @playwright/test. This usually happens`,
81
+ ` when one of the dependencies in your package.json depends on @playwright/test.`
82
+ ].join("\n"));
83
+ }
84
+ return suite;
85
+ }
86
+ _createTest(type, location, title, fnOrDetails, fn) {
87
+ throwIfRunningInsideJest();
88
+ const suite = this._currentSuite(location, "test()");
89
+ if (!suite)
90
+ return;
91
+ let details;
92
+ let body;
93
+ if (typeof fnOrDetails === "function") {
94
+ body = fnOrDetails;
95
+ details = {};
96
+ } else {
97
+ body = fn;
98
+ details = fnOrDetails;
99
+ }
100
+ const validatedDetails = validateTestDetails(details, location);
101
+ const test = new import_test.TestCase(title, body, this, location);
102
+ test._requireFile = suite._requireFile;
103
+ test.annotations.push(...validatedDetails.annotations);
104
+ test._tags.push(...validatedDetails.tags);
105
+ suite._addTest(test);
106
+ if (type === "only" || type === "fail.only")
107
+ test._only = true;
108
+ if (type === "skip" || type === "fixme" || type === "fail")
109
+ test.annotations.push({ type, location });
110
+ else if (type === "fail.only")
111
+ test.annotations.push({ type: "fail", location });
112
+ }
113
+ _describe(type, location, titleOrFn, fnOrDetails, fn) {
114
+ throwIfRunningInsideJest();
115
+ const suite = this._currentSuite(location, "test.describe()");
116
+ if (!suite)
117
+ return;
118
+ let title;
119
+ let body;
120
+ let details;
121
+ if (typeof titleOrFn === "function") {
122
+ title = "";
123
+ details = {};
124
+ body = titleOrFn;
125
+ } else if (typeof fnOrDetails === "function") {
126
+ title = titleOrFn;
127
+ details = {};
128
+ body = fnOrDetails;
129
+ } else {
130
+ title = titleOrFn;
131
+ details = fnOrDetails;
132
+ body = fn;
133
+ }
134
+ const validatedDetails = validateTestDetails(details, location);
135
+ const child = new import_test.Suite(title, "describe");
136
+ child._requireFile = suite._requireFile;
137
+ child.location = location;
138
+ child._staticAnnotations.push(...validatedDetails.annotations);
139
+ child._tags.push(...validatedDetails.tags);
140
+ suite._addSuite(child);
141
+ if (type === "only" || type === "serial.only" || type === "parallel.only")
142
+ child._only = true;
143
+ if (type === "serial" || type === "serial.only")
144
+ child._parallelMode = "serial";
145
+ if (type === "parallel" || type === "parallel.only")
146
+ child._parallelMode = "parallel";
147
+ if (type === "skip" || type === "fixme")
148
+ child._staticAnnotations.push({ type, location });
149
+ for (let parent = suite; parent; parent = parent.parent) {
150
+ if (parent._parallelMode === "serial" && child._parallelMode === "parallel")
151
+ throw new Error("describe.parallel cannot be nested inside describe.serial");
152
+ if (parent._parallelMode === "default" && child._parallelMode === "parallel")
153
+ throw new Error("describe.parallel cannot be nested inside describe with default mode");
154
+ }
155
+ (0, import_globals.setCurrentlyLoadingFileSuite)(child);
156
+ body();
157
+ (0, import_globals.setCurrentlyLoadingFileSuite)(suite);
158
+ }
159
+ _hook(name, location, title, fn) {
160
+ const suite = this._currentSuite(location, `test.${name}()`);
161
+ if (!suite)
162
+ return;
163
+ if (typeof title === "function") {
164
+ fn = title;
165
+ title = `${name} hook`;
166
+ }
167
+ suite._hooks.push({ type: name, fn, title, location });
168
+ }
169
+ _configure(location, options) {
170
+ throwIfRunningInsideJest();
171
+ const suite = this._currentSuite(location, `test.describe.configure()`);
172
+ if (!suite)
173
+ return;
174
+ if (options.timeout !== void 0)
175
+ suite._timeout = options.timeout;
176
+ if (options.retries !== void 0)
177
+ suite._retries = options.retries;
178
+ if (options.mode !== void 0) {
179
+ if (suite._parallelMode !== "none")
180
+ throw new Error(`"${suite._parallelMode}" mode is already assigned for the enclosing scope.`);
181
+ suite._parallelMode = options.mode;
182
+ for (let parent = suite.parent; parent; parent = parent.parent) {
183
+ if (parent._parallelMode === "serial" && suite._parallelMode === "parallel")
184
+ throw new Error("describe with parallel mode cannot be nested inside describe with serial mode");
185
+ if (parent._parallelMode === "default" && suite._parallelMode === "parallel")
186
+ throw new Error("describe with parallel mode cannot be nested inside describe with default mode");
187
+ }
188
+ }
189
+ }
190
+ _modifier(type, location, ...modifierArgs) {
191
+ const suite = (0, import_globals.currentlyLoadingFileSuite)();
192
+ if (suite) {
193
+ if (typeof modifierArgs[0] === "string" && typeof modifierArgs[1] === "function" && (type === "skip" || type === "fixme" || type === "fail")) {
194
+ this._createTest(type, location, modifierArgs[0], modifierArgs[1]);
195
+ return;
196
+ }
197
+ if (typeof modifierArgs[0] === "string" && typeof modifierArgs[1] === "object" && typeof modifierArgs[2] === "function" && (type === "skip" || type === "fixme" || type === "fail")) {
198
+ this._createTest(type, location, modifierArgs[0], modifierArgs[1], modifierArgs[2]);
199
+ return;
200
+ }
201
+ if (typeof modifierArgs[0] === "function") {
202
+ suite._modifiers.push({ type, fn: modifierArgs[0], location, description: modifierArgs[1] });
203
+ } else {
204
+ if (modifierArgs.length >= 1 && !modifierArgs[0])
205
+ return;
206
+ const description = modifierArgs[1];
207
+ suite._staticAnnotations.push({ type, description, location });
208
+ }
209
+ return;
210
+ }
211
+ const testInfo = (0, import_globals.currentTestInfo)();
212
+ if (!testInfo)
213
+ throw new Error(`test.${type}() can only be called inside test, describe block or fixture`);
214
+ if (typeof modifierArgs[0] === "function")
215
+ throw new Error(`test.${type}() with a function can only be called inside describe block`);
216
+ testInfo._modifier(type, location, modifierArgs);
217
+ }
218
+ _setTimeout(location, timeout) {
219
+ const suite = (0, import_globals.currentlyLoadingFileSuite)();
220
+ if (suite) {
221
+ suite._timeout = timeout;
222
+ return;
223
+ }
224
+ const testInfo = (0, import_globals.currentTestInfo)();
225
+ if (!testInfo)
226
+ throw new Error(`test.setTimeout() can only be called from a test`);
227
+ testInfo.setTimeout(timeout);
228
+ }
229
+ _use(location, fixtures) {
230
+ const suite = this._currentSuite(location, `test.use()`);
231
+ if (!suite)
232
+ return;
233
+ suite._use.push({ fixtures, location });
234
+ }
235
+ async _step(expectation, title, body, options = {}) {
236
+ const testInfo = (0, import_globals.currentTestInfo)();
237
+ if (!testInfo)
238
+ throw new Error(`test.step() can only be called from a test`);
239
+ const step = testInfo._addStep({ category: "test.step", title, location: options.location, box: options.box });
240
+ return await (0, import_utils.currentZone)().with("stepZone", step).run(async () => {
241
+ try {
242
+ let result = void 0;
243
+ result = await (0, import_utils.raceAgainstDeadline)(async () => {
244
+ try {
245
+ return await import_stepContext.stepContextStorage.run(step.info, async () => {
246
+ return await step.info._runStepBody(expectation === "skip", body, step.location);
247
+ });
248
+ } catch (e) {
249
+ if (result?.timedOut)
250
+ testInfo._failWithError(e);
251
+ throw e;
252
+ }
253
+ }, options.timeout ? (0, import_utils.monotonicTime)() + options.timeout : 0);
254
+ if (result.timedOut)
255
+ throw new import_playwright_core.errors.TimeoutError(`Step timeout of ${options.timeout}ms exceeded.`);
256
+ step.complete({});
257
+ return result.result;
258
+ } catch (error) {
259
+ step.complete({ error });
260
+ throw error;
261
+ }
262
+ });
263
+ }
264
+ _extend(location, fixtures) {
265
+ if (fixtures[testTypeSymbol])
266
+ throw new Error(`test.extend() accepts fixtures object, not a test object.
267
+ Did you mean to call mergeTests()?`);
268
+ const fixturesWithLocation = { fixtures, location };
269
+ return new TestTypeImpl([...this.fixtures, fixturesWithLocation]).test;
270
+ }
271
+ }
272
+ function throwIfRunningInsideJest() {
273
+ if (process.env.JEST_WORKER_ID) {
274
+ const packageManagerCommand = (0, import_utils.getPackageManagerExecCommand)();
275
+ throw new Error(
276
+ `Playwright Test needs to be invoked via '${packageManagerCommand} playwright test' and excluded from Jest test runs.
277
+ Creating one directory for Playwright tests and one for Jest is the recommended way of doing it.
278
+ See https://playwright.dev/docs/intro for more information about Playwright Test.`
279
+ );
280
+ }
281
+ }
282
+ function validateTestDetails(details, location) {
283
+ const originalAnnotations = Array.isArray(details.annotation) ? details.annotation : details.annotation ? [details.annotation] : [];
284
+ const annotations = originalAnnotations.map((annotation) => ({ ...annotation, location }));
285
+ const tags = Array.isArray(details.tag) ? details.tag : details.tag ? [details.tag] : [];
286
+ for (const tag of tags) {
287
+ if (tag[0] !== "@")
288
+ throw new Error(`Tag must start with "@" symbol, got "${tag}" instead.`);
289
+ }
290
+ return { annotations, tags };
291
+ }
292
+ const rootTestType = new TestTypeImpl([]);
293
+ function mergeTests(...tests) {
294
+ let result = rootTestType;
295
+ for (const t of tests) {
296
+ const testTypeImpl = t[testTypeSymbol];
297
+ if (!testTypeImpl)
298
+ throw new Error(`mergeTests() accepts "test" functions as parameters.
299
+ Did you mean to call test.extend() with fixtures instead?`);
300
+ const newFixtures = testTypeImpl.fixtures.filter((theirs) => !result.fixtures.find((ours) => ours.fixtures === theirs.fixtures));
301
+ result = new TestTypeImpl([...result.fixtures, ...newFixtures]);
302
+ }
303
+ return result.test;
304
+ }
305
+ // Annotate the CommonJS export names for ESM import in node:
306
+ 0 && (module.exports = {
307
+ TestTypeImpl,
308
+ mergeTests,
309
+ rootTestType
310
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/common/testType.ts"],
4
+ "sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { errors } from 'playwright-core';\nimport { getPackageManagerExecCommand, monotonicTime, raceAgainstDeadline, currentZone } from 'playwright-core/lib/utils';\n\nimport { currentTestInfo, currentlyLoadingFileSuite, setCurrentlyLoadingFileSuite } from './globals';\nimport { Suite, TestCase } from './test';\nimport { expect } from '../matchers/expect';\nimport { wrapFunctionWithLocation } from '../transform/transform';\n\nimport type { FixturesWithLocation } from './config';\nimport type { Fixtures, TestDetails, TestStepInfo, TestType } from '../../types/test';\nimport type { Location } from '../../types/testReporter';\n\nconst testTypeSymbol = Symbol('testType');\n\nexport class TestTypeImpl {\n readonly fixtures: FixturesWithLocation[];\n readonly test: TestType<any, any>;\n\n constructor(fixtures: FixturesWithLocation[]) {\n this.fixtures = fixtures;\n\n const test: any = wrapFunctionWithLocation(this._createTest.bind(this, 'default'));\n test[testTypeSymbol] = this;\n test.expect = expect;\n test.only = wrapFunctionWithLocation(this._createTest.bind(this, 'only'));\n test.describe = wrapFunctionWithLocation(this._describe.bind(this, 'default'));\n test.describe.only = wrapFunctionWithLocation(this._describe.bind(this, 'only'));\n test.describe.configure = wrapFunctionWithLocation(this._configure.bind(this));\n test.describe.fixme = wrapFunctionWithLocation(this._describe.bind(this, 'fixme'));\n test.describe.parallel = wrapFunctionWithLocation(this._describe.bind(this, 'parallel'));\n test.describe.parallel.only = wrapFunctionWithLocation(this._describe.bind(this, 'parallel.only'));\n test.describe.serial = wrapFunctionWithLocation(this._describe.bind(this, 'serial'));\n test.describe.serial.only = wrapFunctionWithLocation(this._describe.bind(this, 'serial.only'));\n test.describe.skip = wrapFunctionWithLocation(this._describe.bind(this, 'skip'));\n test.beforeEach = wrapFunctionWithLocation(this._hook.bind(this, 'beforeEach'));\n test.afterEach = wrapFunctionWithLocation(this._hook.bind(this, 'afterEach'));\n test.beforeAll = wrapFunctionWithLocation(this._hook.bind(this, 'beforeAll'));\n test.afterAll = wrapFunctionWithLocation(this._hook.bind(this, 'afterAll'));\n test.skip = wrapFunctionWithLocation(this._modifier.bind(this, 'skip'));\n test.fixme = wrapFunctionWithLocation(this._modifier.bind(this, 'fixme'));\n test.fail = wrapFunctionWithLocation(this._modifier.bind(this, 'fail'));\n test.fail.only = wrapFunctionWithLocation(this._createTest.bind(this, 'fail.only'));\n test.slow = wrapFunctionWithLocation(this._modifier.bind(this, 'slow'));\n test.setTimeout = wrapFunctionWithLocation(this._setTimeout.bind(this));\n test.step = this._step.bind(this, 'pass');\n test.step.skip = this._step.bind(this, 'skip');\n test.use = wrapFunctionWithLocation(this._use.bind(this));\n test.extend = wrapFunctionWithLocation(this._extend.bind(this));\n test.info = () => {\n const result = currentTestInfo();\n if (!result)\n throw new Error('test.info() can only be called while test is running');\n return result;\n };\n this.test = test;\n }\n\n private _currentSuite(location: Location, title: string): Suite | undefined {\n const suite = currentlyLoadingFileSuite();\n if (!suite) {\n throw new Error([\n `Playwright Test did not expect ${title} to be called here.`,\n `Most common reasons include:`,\n `- You are calling ${title} in a configuration file.`,\n `- You are calling ${title} in a file that is imported by the configuration file.`,\n `- You have two different versions of @playwright/test. This usually happens`,\n ` when one of the dependencies in your package.json depends on @playwright/test.`,\n ].join('\\n'));\n }\n return suite;\n }\n\n private _createTest(type: 'default' | 'only' | 'skip' | 'fixme' | 'fail' | 'fail.only', location: Location, title: string, fnOrDetails: Function | TestDetails, fn?: Function) {\n throwIfRunningInsideJest();\n const suite = this._currentSuite(location, 'test()');\n if (!suite)\n return;\n\n let details: TestDetails;\n let body: Function;\n if (typeof fnOrDetails === 'function') {\n body = fnOrDetails;\n details = {};\n } else {\n body = fn!;\n details = fnOrDetails;\n }\n\n const validatedDetails = validateTestDetails(details, location);\n const test = new TestCase(title, body, this, location);\n test._requireFile = suite._requireFile;\n test.annotations.push(...validatedDetails.annotations);\n test._tags.push(...validatedDetails.tags);\n suite._addTest(test);\n\n if (type === 'only' || type === 'fail.only')\n test._only = true;\n if (type === 'skip' || type === 'fixme' || type === 'fail')\n test.annotations.push({ type, location });\n else if (type === 'fail.only')\n test.annotations.push({ type: 'fail', location });\n }\n\n private _describe(type: 'default' | 'only' | 'serial' | 'serial.only' | 'parallel' | 'parallel.only' | 'skip' | 'fixme', location: Location, titleOrFn: string | Function, fnOrDetails?: TestDetails | Function, fn?: Function) {\n throwIfRunningInsideJest();\n const suite = this._currentSuite(location, 'test.describe()');\n if (!suite)\n return;\n\n let title: string;\n let body: Function;\n let details: TestDetails;\n\n if (typeof titleOrFn === 'function') {\n title = '';\n details = {};\n body = titleOrFn;\n } else if (typeof fnOrDetails === 'function') {\n title = titleOrFn;\n details = {};\n body = fnOrDetails;\n } else {\n title = titleOrFn;\n details = fnOrDetails!;\n body = fn!;\n }\n\n const validatedDetails = validateTestDetails(details, location);\n const child = new Suite(title, 'describe');\n child._requireFile = suite._requireFile;\n child.location = location;\n child._staticAnnotations.push(...validatedDetails.annotations);\n child._tags.push(...validatedDetails.tags);\n suite._addSuite(child);\n\n if (type === 'only' || type === 'serial.only' || type === 'parallel.only')\n child._only = true;\n if (type === 'serial' || type === 'serial.only')\n child._parallelMode = 'serial';\n if (type === 'parallel' || type === 'parallel.only')\n child._parallelMode = 'parallel';\n if (type === 'skip' || type === 'fixme')\n child._staticAnnotations.push({ type, location });\n\n for (let parent: Suite | undefined = suite; parent; parent = parent.parent) {\n if (parent._parallelMode === 'serial' && child._parallelMode === 'parallel')\n throw new Error('describe.parallel cannot be nested inside describe.serial');\n if (parent._parallelMode === 'default' && child._parallelMode === 'parallel')\n throw new Error('describe.parallel cannot be nested inside describe with default mode');\n }\n\n setCurrentlyLoadingFileSuite(child);\n body();\n setCurrentlyLoadingFileSuite(suite);\n }\n\n private _hook(name: 'beforeEach' | 'afterEach' | 'beforeAll' | 'afterAll', location: Location, title: string | Function, fn?: Function) {\n const suite = this._currentSuite(location, `test.${name}()`);\n if (!suite)\n return;\n if (typeof title === 'function') {\n fn = title;\n title = `${name} hook`;\n }\n\n suite._hooks.push({ type: name, fn: fn!, title, location });\n }\n\n private _configure(location: Location, options: { mode?: 'default' | 'parallel' | 'serial', retries?: number, timeout?: number }) {\n throwIfRunningInsideJest();\n const suite = this._currentSuite(location, `test.describe.configure()`);\n if (!suite)\n return;\n\n if (options.timeout !== undefined)\n suite._timeout = options.timeout;\n\n if (options.retries !== undefined)\n suite._retries = options.retries;\n\n if (options.mode !== undefined) {\n if (suite._parallelMode !== 'none')\n throw new Error(`\"${suite._parallelMode}\" mode is already assigned for the enclosing scope.`);\n suite._parallelMode = options.mode;\n for (let parent: Suite | undefined = suite.parent; parent; parent = parent.parent) {\n if (parent._parallelMode === 'serial' && suite._parallelMode === 'parallel')\n throw new Error('describe with parallel mode cannot be nested inside describe with serial mode');\n if (parent._parallelMode === 'default' && suite._parallelMode === 'parallel')\n throw new Error('describe with parallel mode cannot be nested inside describe with default mode');\n }\n }\n }\n\n private _modifier(type: 'skip' | 'fail' | 'fixme' | 'slow', location: Location, ...modifierArgs: any[]) {\n const suite = currentlyLoadingFileSuite();\n if (suite) {\n if (typeof modifierArgs[0] === 'string' && typeof modifierArgs[1] === 'function' && (type === 'skip' || type === 'fixme' || type === 'fail')) {\n // Support for test.{skip,fixme,fail}(title, body)\n this._createTest(type, location, modifierArgs[0], modifierArgs[1]);\n return;\n }\n if (typeof modifierArgs[0] === 'string' && typeof modifierArgs[1] === 'object' && typeof modifierArgs[2] === 'function' && (type === 'skip' || type === 'fixme' || type === 'fail')) {\n // Support for test.{skip,fixme,fail}(title, details, body)\n this._createTest(type, location, modifierArgs[0], modifierArgs[1], modifierArgs[2]);\n return;\n }\n\n if (typeof modifierArgs[0] === 'function') {\n suite._modifiers.push({ type, fn: modifierArgs[0], location, description: modifierArgs[1] });\n } else {\n if (modifierArgs.length >= 1 && !modifierArgs[0])\n return;\n const description = modifierArgs[1];\n suite._staticAnnotations.push({ type, description, location });\n }\n return;\n }\n\n const testInfo = currentTestInfo();\n if (!testInfo)\n throw new Error(`test.${type}() can only be called inside test, describe block or fixture`);\n if (typeof modifierArgs[0] === 'function')\n throw new Error(`test.${type}() with a function can only be called inside describe block`);\n testInfo._modifier(type, location, modifierArgs as [any, any]);\n }\n\n private _setTimeout(location: Location, timeout: number) {\n const suite = currentlyLoadingFileSuite();\n if (suite) {\n suite._timeout = timeout;\n return;\n }\n\n const testInfo = currentTestInfo();\n if (!testInfo)\n throw new Error(`test.setTimeout() can only be called from a test`);\n testInfo.setTimeout(timeout);\n }\n\n private _use(location: Location, fixtures: Fixtures) {\n const suite = this._currentSuite(location, `test.use()`);\n if (!suite)\n return;\n suite._use.push({ fixtures, location });\n }\n\n async _step<T>(expectation: 'pass'|'skip', title: string, body: (step: TestStepInfo) => T | Promise<T>, options: {box?: boolean, location?: Location, timeout?: number } = {}): Promise<T> {\n const testInfo = currentTestInfo();\n if (!testInfo)\n throw new Error(`test.step() can only be called from a test`);\n const step = testInfo._addStep({ category: 'test.step', title, location: options.location, box: options.box });\n return await currentZone().with('stepZone', step).run(async () => {\n try {\n let result: Awaited<ReturnType<typeof raceAgainstDeadline<T>>> | undefined = undefined;\n result = await raceAgainstDeadline(async () => {\n try {\n return await step.info._runStepBody(expectation === 'skip', body, step.location);\n } catch (e) {\n // If the step timed out, the test fixtures will tear down, which in turn\n // will abort unfinished actions in the step body. Record such errors here.\n if (result?.timedOut)\n testInfo._failWithError(e);\n throw e;\n }\n }, options.timeout ? monotonicTime() + options.timeout : 0);\n if (result.timedOut)\n throw new errors.TimeoutError(`Step timeout of ${options.timeout}ms exceeded.`);\n step.complete({});\n return result.result;\n } catch (error) {\n step.complete({ error });\n throw error;\n }\n });\n }\n\n private _extend(location: Location, fixtures: Fixtures) {\n if ((fixtures as any)[testTypeSymbol])\n throw new Error(`test.extend() accepts fixtures object, not a test object.\\nDid you mean to call mergeTests()?`);\n const fixturesWithLocation: FixturesWithLocation = { fixtures, location };\n return new TestTypeImpl([...this.fixtures, fixturesWithLocation]).test;\n }\n}\n\nfunction throwIfRunningInsideJest() {\n if (process.env.JEST_WORKER_ID) {\n const packageManagerCommand = getPackageManagerExecCommand();\n throw new Error(\n `Playwright Test needs to be invoked via '${packageManagerCommand} playwright test' and excluded from Jest test runs.\\n` +\n `Creating one directory for Playwright tests and one for Jest is the recommended way of doing it.\\n` +\n `See https://playwright.dev/docs/intro for more information about Playwright Test.`,\n );\n }\n}\n\nfunction validateTestDetails(details: TestDetails, location: Location) {\n const originalAnnotations = Array.isArray(details.annotation) ? details.annotation : (details.annotation ? [details.annotation] : []);\n const annotations = originalAnnotations.map(annotation => ({ ...annotation, location }));\n const tags = Array.isArray(details.tag) ? details.tag : (details.tag ? [details.tag] : []);\n for (const tag of tags) {\n if (tag[0] !== '@')\n throw new Error(`Tag must start with \"@\" symbol, got \"${tag}\" instead.`);\n }\n return { annotations, tags };\n}\n\nexport const rootTestType = new TestTypeImpl([]);\n\nexport function mergeTests(...tests: TestType<any, any>[]) {\n let result = rootTestType;\n for (const t of tests) {\n const testTypeImpl = (t as any)[testTypeSymbol] as TestTypeImpl;\n if (!testTypeImpl)\n throw new Error(`mergeTests() accepts \"test\" functions as parameters.\\nDid you mean to call test.extend() with fixtures instead?`);\n // Filter out common ancestor fixtures.\n const newFixtures = testTypeImpl.fixtures.filter(theirs => !result.fixtures.find(ours => ours.fixtures === theirs.fixtures));\n result = new TestTypeImpl([...result.fixtures, ...newFixtures]);\n }\n return result.test;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,6BAAuB;AACvB,mBAA8F;AAE9F,qBAAyF;AACzF,kBAAgC;AAChC,oBAAuB;AACvB,uBAAyC;AAMzC,MAAM,iBAAiB,OAAO,UAAU;AAEjC,MAAM,aAAa;AAAA,EAIxB,YAAY,UAAkC;AAC5C,SAAK,WAAW;AAEhB,UAAM,WAAY,2CAAyB,KAAK,YAAY,KAAK,MAAM,SAAS,CAAC;AACjF,SAAK,cAAc,IAAI;AACvB,SAAK,SAAS;AACd,SAAK,WAAO,2CAAyB,KAAK,YAAY,KAAK,MAAM,MAAM,CAAC;AACxE,SAAK,eAAW,2CAAyB,KAAK,UAAU,KAAK,MAAM,SAAS,CAAC;AAC7E,SAAK,SAAS,WAAO,2CAAyB,KAAK,UAAU,KAAK,MAAM,MAAM,CAAC;AAC/E,SAAK,SAAS,gBAAY,2CAAyB,KAAK,WAAW,KAAK,IAAI,CAAC;AAC7E,SAAK,SAAS,YAA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IAAI,iBAAe,EAAE,GAAG,YAAY,SAAS,EAAE;AACvF,QAAM,OAAO,MAAM,QAAQ,QAAQ,GAAG,IAAI,QAAQ,MAAO,QAAQ,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;AACxF,aAAW,OAAO,MAAM;AACtB,QAAI,IAAI,CAAC,MAAM;AACb,YAAM,IAAI,MAAM,wCAAwC,GAAG,YAAY;AAAA,EAC3E;AACA,SAAO,EAAE,aAAa,KAAK;AAC7B;AAEO,MAAM,eAAe,IAAI,aAAa,CAAC,CAAC;AAExC,SAAS,cAAc,OAA6B;AACzD,MAAI,SAAS;AACb,aAAW,KAAK,OAAO;AACrB,UAAM,eAAgB,EAAU,cAAc;AAC9C,QAAI,CAAC;AACH,YAAM,IAAI,MAAM;AAAA,0DAAiH;AAEnI,UAAM,cAAc,aAAa,SAAS,OAAO,YAAU,CAAC,OAAO,SAAS,KAAK,UAAQ,KAAK,aAAa,OAAO,QAAQ,CAAC;AAC3H,aAAS,IAAI,aAAa,CAAC,GAAG,OAAO,UAAU,GAAG,WAAW,CAAC;AAAA,EAChE;AACA,SAAO,OAAO;AAChB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var fsWatcher_exports = {};
20
+ __export(fsWatcher_exports, {
21
+ Watcher: () => Watcher
22
+ });
23
+ module.exports = __toCommonJS(fsWatcher_exports);
24
+ var import_utilsBundle = require("./utilsBundle");
25
+ class Watcher {
26
+ constructor(onChange) {
27
+ this._watchedPaths = [];
28
+ this._ignoredFolders = [];
29
+ this._collector = [];
30
+ this._onChange = onChange;
31
+ }
32
+ async update(watchedPaths, ignoredFolders, reportPending) {
33
+ if (JSON.stringify([this._watchedPaths, this._ignoredFolders]) === JSON.stringify([watchedPaths, ignoredFolders]))
34
+ return;
35
+ if (reportPending)
36
+ this._reportEventsIfAny();
37
+ this._watchedPaths = watchedPaths;
38
+ this._ignoredFolders = ignoredFolders;
39
+ void this._fsWatcher?.close();
40
+ this._fsWatcher = void 0;
41
+ this._collector.length = 0;
42
+ clearTimeout(this._throttleTimer);
43
+ this._throttleTimer = void 0;
44
+ if (!this._watchedPaths.length)
45
+ return;
46
+ const ignored = [...this._ignoredFolders, "**/node_modules/**"];
47
+ this._fsWatcher = import_utilsBundle.chokidar.watch(watchedPaths, { ignoreInitial: true, ignored }).on("all", async (event, file) => {
48
+ if (this._throttleTimer)
49
+ clearTimeout(this._throttleTimer);
50
+ this._collector.push({ event, file });
51
+ this._throttleTimer = setTimeout(() => this._reportEventsIfAny(), 250);
52
+ });
53
+ await new Promise((resolve, reject) => this._fsWatcher.once("ready", resolve).once("error", reject));
54
+ }
55
+ async close() {
56
+ await this._fsWatcher?.close();
57
+ }
58
+ _reportEventsIfAny() {
59
+ if (this._collector.length)
60
+ this._onChange(this._collector.slice());
61
+ this._collector.length = 0;
62
+ }
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ Watcher
67
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/fsWatcher.ts"],
4
+ "sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { chokidar } from './utilsBundle';\n\nimport type { FSWatcher } from 'chokidar';\n\nexport type FSEvent = { event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', file: string };\n\nexport class Watcher {\n private _onChange: (events: FSEvent[]) => void;\n private _watchedPaths: string[] = [];\n private _ignoredFolders: string[] = [];\n private _collector: FSEvent[] = [];\n private _fsWatcher: FSWatcher | undefined;\n private _throttleTimer: NodeJS.Timeout | undefined;\n\n constructor(onChange: (events: FSEvent[]) => void) {\n this._onChange = onChange;\n }\n\n async update(watchedPaths: string[], ignoredFolders: string[], reportPending: boolean) {\n if (JSON.stringify([this._watchedPaths, this._ignoredFolders]) === JSON.stringify([watchedPaths, ignoredFolders]))\n return;\n\n if (reportPending)\n this._reportEventsIfAny();\n\n this._watchedPaths = watchedPaths;\n this._ignoredFolders = ignoredFolders;\n void this._fsWatcher?.close();\n this._fsWatcher = undefined;\n this._collector.length = 0;\n clearTimeout(this._throttleTimer);\n this._throttleTimer = undefined;\n\n if (!this._watchedPaths.length)\n return;\n\n const ignored = [...this._ignoredFolders, '**/node_modules/**'];\n this._fsWatcher = chokidar.watch(watchedPaths, { ignoreInitial: true, ignored }).on('all', async (event, file) => {\n if (this._throttleTimer)\n clearTimeout(this._throttleTimer);\n this._collector.push({ event, file });\n this._throttleTimer = setTimeout(() => this._reportEventsIfAny(), 250);\n });\n\n await new Promise((resolve, reject) => this._fsWatcher!.once('ready', resolve).once('error', reject));\n }\n\n async close() {\n await this._fsWatcher?.close();\n }\n\n private _reportEventsIfAny() {\n if (this._collector.length)\n this._onChange(this._collector.slice());\n this._collector.length = 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