@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,302 @@
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 fixtures_exports = {};
30
+ __export(fixtures_exports, {
31
+ FixturePool: () => FixturePool,
32
+ fixtureParameterNames: () => fixtureParameterNames,
33
+ formatPotentiallyInternalLocation: () => formatPotentiallyInternalLocation,
34
+ inheritFixtureNames: () => inheritFixtureNames
35
+ });
36
+ module.exports = __toCommonJS(fixtures_exports);
37
+ var import_crypto = __toESM(require("crypto"));
38
+ var import_util = require("../util");
39
+ const kScopeOrder = ["test", "worker"];
40
+ function isFixtureTuple(value) {
41
+ return Array.isArray(value) && typeof value[1] === "object";
42
+ }
43
+ function isFixtureOption(value) {
44
+ return isFixtureTuple(value) && !!value[1].option;
45
+ }
46
+ class FixturePool {
47
+ constructor(fixturesList, onLoadError, parentPool, disallowWorkerFixtures, optionOverrides) {
48
+ this._registrations = new Map(parentPool ? parentPool._registrations : []);
49
+ this._onLoadError = onLoadError;
50
+ const allOverrides = optionOverrides?.overrides ?? {};
51
+ const overrideKeys = new Set(Object.keys(allOverrides));
52
+ for (const list of fixturesList) {
53
+ this._appendFixtureList(list, !!disallowWorkerFixtures, false);
54
+ const selectedOverrides = {};
55
+ for (const [key, value] of Object.entries(list.fixtures)) {
56
+ if (isFixtureOption(value) && overrideKeys.has(key))
57
+ selectedOverrides[key] = [allOverrides[key], value[1]];
58
+ }
59
+ if (Object.entries(selectedOverrides).length)
60
+ this._appendFixtureList({ fixtures: selectedOverrides, location: optionOverrides.location }, !!disallowWorkerFixtures, true);
61
+ }
62
+ this.digest = this.validate();
63
+ }
64
+ _appendFixtureList(list, disallowWorkerFixtures, isOptionsOverride) {
65
+ const { fixtures, location } = list;
66
+ for (const entry of Object.entries(fixtures)) {
67
+ const name = entry[0];
68
+ let value = entry[1];
69
+ let options;
70
+ if (isFixtureTuple(value)) {
71
+ options = {
72
+ auto: value[1].auto ?? false,
73
+ scope: value[1].scope || "test",
74
+ option: !!value[1].option,
75
+ timeout: value[1].timeout,
76
+ customTitle: value[1].title,
77
+ box: value[1].box
78
+ };
79
+ value = value[0];
80
+ }
81
+ let fn = value;
82
+ const previous = this._registrations.get(name);
83
+ if (previous && options) {
84
+ if (previous.scope !== options.scope) {
85
+ this._addLoadError(`Fixture "${name}" has already been registered as a { scope: '${previous.scope}' } fixture defined in ${(0, import_util.formatLocation)(previous.location)}.`, location);
86
+ continue;
87
+ }
88
+ if (previous.auto !== options.auto) {
89
+ this._addLoadError(`Fixture "${name}" has already been registered as a { auto: '${previous.scope}' } fixture defined in ${(0, import_util.formatLocation)(previous.location)}.`, location);
90
+ continue;
91
+ }
92
+ } else if (previous) {
93
+ options = { auto: previous.auto, scope: previous.scope, option: previous.option, timeout: previous.timeout, customTitle: previous.customTitle };
94
+ } else if (!options) {
95
+ options = { auto: false, scope: "test", option: false, timeout: void 0 };
96
+ }
97
+ if (!kScopeOrder.includes(options.scope)) {
98
+ this._addLoadError(`Fixture "${name}" has unknown { scope: '${options.scope}' }.`, location);
99
+ continue;
100
+ }
101
+ if (options.scope === "worker" && disallowWorkerFixtures) {
102
+ this._addLoadError(`Cannot use({ ${name} }) in a describe group, because it forces a new worker.
103
+ Make it top-level in the test file or put in the configuration file.`, location);
104
+ continue;
105
+ }
106
+ if (fn === void 0 && options.option && previous) {
107
+ let original = previous;
108
+ while (!original.optionOverride && original.super)
109
+ original = original.super;
110
+ fn = original.fn;
111
+ }
112
+ const deps = fixtureParameterNames(fn, location, (e) => this._onLoadError(e));
113
+ const registration = { id: "", name, location, scope: options.scope, fn, auto: options.auto, option: options.option, timeout: options.timeout, customTitle: options.customTitle, box: options.box, deps, super: previous, optionOverride: isOptionsOverride };
114
+ registrationId(registration);
115
+ this._registrations.set(name, registration);
116
+ }
117
+ }
118
+ validate() {
119
+ const markers = /* @__PURE__ */ new Map();
120
+ const stack = [];
121
+ let hasDependencyErrors = false;
122
+ const addDependencyError = (message, location) => {
123
+ hasDependencyErrors = true;
124
+ this._addLoadError(message, location);
125
+ };
126
+ const visit = (registration, boxedOnly) => {
127
+ markers.set(registration, "visiting");
128
+ stack.push(registration);
129
+ for (const name of registration.deps) {
130
+ const dep = this.resolve(name, registration);
131
+ if (!dep) {
132
+ if (name === registration.name)
133
+ addDependencyError(`Fixture "${registration.name}" references itself, but does not have a base implementation.`, registration.location);
134
+ else
135
+ addDependencyError(`Fixture "${registration.name}" has unknown parameter "${name}".`, registration.location);
136
+ continue;
137
+ }
138
+ if (kScopeOrder.indexOf(registration.scope) > kScopeOrder.indexOf(dep.scope)) {
139
+ addDependencyError(`${registration.scope} fixture "${registration.name}" cannot depend on a ${dep.scope} fixture "${name}" defined in ${formatPotentiallyInternalLocation(dep.location)}.`, registration.location);
140
+ continue;
141
+ }
142
+ if (!markers.has(dep)) {
143
+ visit(dep, boxedOnly);
144
+ } else if (markers.get(dep) === "visiting") {
145
+ const index = stack.indexOf(dep);
146
+ const allRegs = stack.slice(index, stack.length);
147
+ const filteredRegs = allRegs.filter((r) => !r.box);
148
+ const regs = boxedOnly ? filteredRegs : allRegs;
149
+ const names2 = regs.map((r) => `"${r.name}"`);
150
+ addDependencyError(`Fixtures ${names2.join(" -> ")} -> "${dep.name}" form a dependency cycle: ${regs.map((r) => formatPotentiallyInternalLocation(r.location)).join(" -> ")} -> ${formatPotentiallyInternalLocation(dep.location)}`, dep.location);
151
+ continue;
152
+ }
153
+ }
154
+ markers.set(registration, "visited");
155
+ stack.pop();
156
+ };
157
+ const names = Array.from(this._registrations.keys()).sort();
158
+ for (const name of names) {
159
+ const registration = this._registrations.get(name);
160
+ if (!registration.box)
161
+ visit(registration, true);
162
+ }
163
+ if (!hasDependencyErrors) {
164
+ for (const name of names) {
165
+ const registration = this._registrations.get(name);
166
+ if (registration.box)
167
+ visit(registration, false);
168
+ }
169
+ }
170
+ const hash = import_crypto.default.createHash("sha1");
171
+ for (const name of names) {
172
+ const registration = this._registrations.get(name);
173
+ if (registration.scope === "worker")
174
+ hash.update(registration.id + ";");
175
+ }
176
+ return hash.digest("hex");
177
+ }
178
+ validateFunction(fn, prefix, location) {
179
+ for (const name of fixtureParameterNames(fn, location, (e) => this._onLoadError(e))) {
180
+ const registration = this._registrations.get(name);
181
+ if (!registration)
182
+ this._addLoadError(`${prefix} has unknown parameter "${name}".`, location);
183
+ }
184
+ }
185
+ resolve(name, forFixture) {
186
+ if (name === forFixture?.name)
187
+ return forFixture.super;
188
+ return this._registrations.get(name);
189
+ }
190
+ autoFixtures() {
191
+ return [...this._registrations.values()].filter((r) => r.auto !== false);
192
+ }
193
+ _addLoadError(message, location) {
194
+ this._onLoadError({ message, location });
195
+ }
196
+ }
197
+ const signatureSymbol = Symbol("signature");
198
+ function formatPotentiallyInternalLocation(location) {
199
+ const isUserFixture = location && (0, import_util.filterStackFile)(location.file);
200
+ return isUserFixture ? (0, import_util.formatLocation)(location) : "<builtin>";
201
+ }
202
+ function fixtureParameterNames(fn, location, onError) {
203
+ if (typeof fn !== "function")
204
+ return [];
205
+ if (!fn[signatureSymbol])
206
+ fn[signatureSymbol] = innerFixtureParameterNames(fn, location, onError);
207
+ return fn[signatureSymbol];
208
+ }
209
+ function inheritFixtureNames(from, to) {
210
+ to[signatureSymbol] = from[signatureSymbol];
211
+ }
212
+ function innerFixtureParameterNames(fn, location, onError) {
213
+ const text = filterOutComments(fn.toString());
214
+ const match = text.match(/(?:async)?(?:\s+function)?[^(]*\(([^)]*)/);
215
+ if (!match)
216
+ return [];
217
+ const trimmedParams = match[1].trim();
218
+ if (!trimmedParams)
219
+ return [];
220
+ const [firstParam] = splitByComma(trimmedParams);
221
+ if (firstParam[0] !== "{" || firstParam[firstParam.length - 1] !== "}") {
222
+ onError({ message: "First argument must use the object destructuring pattern: " + firstParam, location });
223
+ return [];
224
+ }
225
+ const props = splitByComma(firstParam.substring(1, firstParam.length - 1)).map((prop) => {
226
+ const colon = prop.indexOf(":");
227
+ return colon === -1 ? prop.trim() : prop.substring(0, colon).trim();
228
+ });
229
+ const restProperty = props.find((prop) => prop.startsWith("..."));
230
+ if (restProperty) {
231
+ onError({ message: `Rest property "${restProperty}" is not supported. List all used fixtures explicitly, separated by comma.`, location });
232
+ return [];
233
+ }
234
+ return props;
235
+ }
236
+ function filterOutComments(s) {
237
+ const result = [];
238
+ let commentState = "none";
239
+ for (let i = 0; i < s.length; ++i) {
240
+ if (commentState === "singleline") {
241
+ if (s[i] === "\n")
242
+ commentState = "none";
243
+ } else if (commentState === "multiline") {
244
+ if (s[i - 1] === "*" && s[i] === "/")
245
+ commentState = "none";
246
+ } else if (commentState === "none") {
247
+ if (s[i] === "/" && s[i + 1] === "/") {
248
+ commentState = "singleline";
249
+ } else if (s[i] === "/" && s[i + 1] === "*") {
250
+ commentState = "multiline";
251
+ i += 2;
252
+ } else {
253
+ result.push(s[i]);
254
+ }
255
+ }
256
+ }
257
+ return result.join("");
258
+ }
259
+ function splitByComma(s) {
260
+ const result = [];
261
+ const stack = [];
262
+ let start = 0;
263
+ for (let i = 0; i < s.length; i++) {
264
+ if (s[i] === "{" || s[i] === "[") {
265
+ stack.push(s[i] === "{" ? "}" : "]");
266
+ } else if (s[i] === stack[stack.length - 1]) {
267
+ stack.pop();
268
+ } else if (!stack.length && s[i] === ",") {
269
+ const token = s.substring(start, i).trim();
270
+ if (token)
271
+ result.push(token);
272
+ start = i + 1;
273
+ }
274
+ }
275
+ const lastToken = s.substring(start).trim();
276
+ if (lastToken)
277
+ result.push(lastToken);
278
+ return result;
279
+ }
280
+ const registrationIdMap = /* @__PURE__ */ new Map();
281
+ let lastId = 0;
282
+ function registrationId(registration) {
283
+ if (registration.id)
284
+ return registration.id;
285
+ const key = registration.name + "@@@" + (registration.super ? registrationId(registration.super) : "");
286
+ let map = registrationIdMap.get(key);
287
+ if (!map) {
288
+ map = /* @__PURE__ */ new Map();
289
+ registrationIdMap.set(key, map);
290
+ }
291
+ if (!map.has(registration.fn))
292
+ map.set(registration.fn, String(lastId++));
293
+ registration.id = map.get(registration.fn);
294
+ return registration.id;
295
+ }
296
+ // Annotate the CommonJS export names for ESM import in node:
297
+ 0 && (module.exports = {
298
+ FixturePool,
299
+ fixtureParameterNames,
300
+ formatPotentiallyInternalLocation,
301
+ inheritFixtureNames
302
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/common/fixtures.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 crypto from 'crypto';\n\nimport { filterStackFile, formatLocation } from '../util';\n\nimport type { FixturesWithLocation } from './config';\nimport type { Fixtures } from '../../types/test';\nimport type { Location } from '../../types/testReporter';\n\nexport type FixtureScope = 'test' | 'worker';\ntype FixtureAuto = boolean | 'all-hooks-included';\nconst kScopeOrder: FixtureScope[] = ['test', 'worker'];\ntype FixtureOptions = { auto?: FixtureAuto, scope?: FixtureScope, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean };\ntype FixtureTuple = [ value: any, options: FixtureOptions ];\nexport type FixtureRegistration = {\n // Fixture registration location.\n location: Location;\n // Fixture name comes from test.extend() call.\n name: string;\n scope: FixtureScope;\n // Either a fixture function, or a fixture value.\n fn: Function | any;\n // Auto fixtures always run without user explicitly mentioning them.\n auto: FixtureAuto;\n // An \"option\" fixture can have a value set in the config.\n option: boolean;\n // Custom title to be used instead of the name, internal-only.\n customTitle?: string;\n // Fixture with a separate timeout does not count towards the test time.\n timeout?: number;\n // Names of the dependencies, comes from the declaration \"({ foo, bar }) => {...}\"\n deps: string[];\n // Unique id, to differentiate between fixtures with the same name.\n id: string;\n // A fixture override can use the previous version of the fixture.\n super?: FixtureRegistration;\n // Whether this fixture is an option override value set from the config.\n optionOverride?: boolean;\n // Do not generate the step for this fixture, consider it internal.\n box?: boolean;\n};\nexport type LoadError = {\n message: string;\n location: Location;\n};\ntype LoadErrorSink = (error: LoadError) => void;\ntype OptionOverrides = {\n overrides: Fixtures,\n location: Location,\n};\n\nfunction isFixtureTuple(value: any): value is FixtureTuple {\n return Array.isArray(value) && typeof value[1] === 'object';\n}\n\nfunction isFixtureOption(value: any): value is FixtureTuple {\n return isFixtureTuple(value) && !!value[1].option;\n}\n\nexport class FixturePool {\n readonly digest: string;\n private readonly _registrations: Map<string, FixtureRegistration>;\n private _onLoadError: LoadErrorSink;\n\n constructor(fixturesList: FixturesWithLocation[], onLoadError: LoadErrorSink, parentPool?: FixturePool, disallowWorkerFixtures?: boolean, optionOverrides?: OptionOverrides) {\n this._registrations = new Map(parentPool ? parentPool._registrations : []);\n this._onLoadError = onLoadError;\n\n const allOverrides = optionOverrides?.overrides ?? {};\n const overrideKeys = new Set(Object.keys(allOverrides));\n for (const list of fixturesList) {\n this._appendFixtureList(list, !!disallowWorkerFixtures, false);\n\n // Process option overrides immediately after original option definitions,\n // so that any test.use() override it.\n const selectedOverrides: Fixtures = {};\n for (const [key, value] of Object.entries(list.fixtures)) {\n if (isFixtureOption(value) && overrideKeys.has(key))\n (selectedOverrides as any)[key] = [(allOverrides as any)[key], value[1]];\n }\n if (Object.entries(selectedOverrides).length)\n this._appendFixtureList({ fixtures: selectedOverrides, location: optionOverrides!.location }, !!disallowWorkerFixtures, true);\n }\n\n this.digest = this.validate();\n }\n\n private _appendFixtureList(list: FixturesWithLocation, disallowWorkerFixtures: boolean, isOptionsOverride: boolean) {\n const { fixtures, location } = list;\n for (const entry of Object.entries(fixtures)) {\n const name = entry[0];\n let value = entry[1];\n let options: { auto: FixtureAuto, scope: FixtureScope, option: boolean, timeout: number | undefined, customTitle?: string, box?: boolean } | undefined;\n if (isFixtureTuple(value)) {\n options = {\n auto: value[1].auto ?? false,\n scope: value[1].scope || 'test',\n option: !!value[1].option,\n timeout: value[1].timeout,\n customTitle: value[1].title,\n box: value[1].box,\n };\n value = value[0];\n }\n let fn = value as (Function | any);\n\n const previous = this._registrations.get(name);\n if (previous && options) {\n if (previous.scope !== options.scope) {\n this._addLoadError(`Fixture \"${name}\" has already been registered as a { scope: '${previous.scope}' } fixture defined in ${formatLocation(previous.location)}.`, location);\n continue;\n }\n if (previous.auto !== options.auto) {\n this._addLoadError(`Fixture \"${name}\" has already been registered as a { auto: '${previous.scope}' } fixture defined in ${formatLocation(previous.location)}.`, location);\n continue;\n }\n } else if (previous) {\n // Note: deliberately not inheriting \"options.box\" so that fixture override is visible by default.\n options = { auto: previous.auto, scope: previous.scope, option: previous.option, timeout: previous.timeout, customTitle: previous.customTitle };\n } else if (!options) {\n options = { auto: false, scope: 'test', option: false, timeout: undefined };\n }\n\n if (!kScopeOrder.includes(options.scope)) {\n this._addLoadError(`Fixture \"${name}\" has unknown { scope: '${options.scope}' }.`, location);\n continue;\n }\n if (options.scope === 'worker' && disallowWorkerFixtures) {\n this._addLoadError(`Cannot use({ ${name} }) in a describe group, because it forces a new worker.\\nMake it top-level in the test file or put in the configuration file.`, location);\n continue;\n }\n\n // Overriding option with \"undefined\" value means setting it to the default value\n // from the config or from the original declaration of the option.\n if (fn === undefined && options.option && previous) {\n let original = previous;\n while (!original.optionOverride && original.super)\n original = original.super;\n fn = original.fn;\n }\n\n const deps = fixtureParameterNames(fn, location, e => this._onLoadError(e));\n const registration: FixtureRegistration = { id: '', name, location, scope: options.scope, fn, auto: options.auto, option: options.option, timeout: options.timeout, customTitle: options.customTitle, box: options.box, deps, super: previous, optionOverride: isOptionsOverride };\n registrationId(registration);\n this._registrations.set(name, registration);\n }\n }\n\n private validate() {\n const markers = new Map<FixtureRegistration, 'visiting' | 'visited'>();\n const stack: FixtureRegistration[] = [];\n let hasDependencyErrors = false;\n const addDependencyError = (message: string, location: Location) => {\n hasDependencyErrors = true;\n this._addLoadError(message, location);\n };\n const visit = (registration: FixtureRegistration, boxedOnly: boolean) => {\n markers.set(registration, 'visiting');\n stack.push(registration);\n for (const name of registration.deps) {\n const dep = this.resolve(name, registration);\n if (!dep) {\n if (name === registration.name)\n addDependencyError(`Fixture \"${registration.name}\" references itself, but does not have a base implementation.`, registration.location);\n else\n addDependencyError(`Fixture \"${registration.name}\" has unknown parameter \"${name}\".`, registration.location);\n continue;\n }\n if (kScopeOrder.indexOf(registration.scope) > kScopeOrder.indexOf(dep.scope)) {\n addDependencyError(`${registration.scope} fixture \"${registration.name}\" cannot depend on a ${dep.scope} fixture \"${name}\" defined in ${formatPotentiallyInternalLocation(dep.location)}.`, registration.location);\n continue;\n }\n if (!markers.has(dep)) {\n visit(dep, boxedOnly);\n } else if (markers.get(dep) === 'visiting') {\n const index = stack.indexOf(dep);\n const allRegs = stack.slice(index, stack.length);\n const filteredRegs = allRegs.filter(r => !r.box);\n const regs = boxedOnly ? filteredRegs : allRegs;\n const names = regs.map(r => `\"${r.name}\"`);\n addDependencyError(`Fixtures ${names.join(' -> ')} -> \"${dep.name}\" form a dependency cycle: ${regs.map(r => formatPotentiallyInternalLocation(r.location)).join(' -> ')} -> ${formatPotentiallyInternalLocation(dep.location)}`, dep.location);\n continue;\n }\n }\n markers.set(registration, 'visited');\n stack.pop();\n };\n\n const names = Array.from(this._registrations.keys()).sort();\n\n // First iterate over non-boxed fixtures to provide clear error messages.\n for (const name of names) {\n const registration = this._registrations.get(name)!;\n if (!registration.box)\n visit(registration, true);\n }\n\n // If no errors found, iterate over boxed fixtures\n if (!hasDependencyErrors) {\n for (const name of names) {\n const registration = this._registrations.get(name)!;\n if (registration.box)\n visit(registration, false);\n }\n }\n\n const hash = crypto.createHash('sha1');\n for (const name of names) {\n const registration = this._registrations.get(name)!;\n if (registration.scope === 'worker')\n hash.update(registration.id + ';');\n }\n return hash.digest('hex');\n }\n\n validateFunction(fn: Function, prefix: string, location: Location) {\n for (const name of fixtureParameterNames(fn, location, e => this._onLoadError(e))) {\n const registration = this._registrations.get(name);\n if (!registration)\n this._addLoadError(`${prefix} has unknown parameter \"${name}\".`, location);\n }\n }\n\n resolve(name: string, forFixture?: FixtureRegistration): FixtureRegistration | undefined {\n if (name === forFixture?.name)\n return forFixture.super;\n return this._registrations.get(name);\n }\n\n autoFixtures() {\n return [...this._registrations.values()].filter(r => r.auto !== false);\n }\n\n private _addLoadError(message: string, location: Location) {\n this._onLoadError({ message, location });\n }\n}\n\nconst signatureSymbol = Symbol('signature');\n\nexport function formatPotentiallyInternalLocation(location: Location): string {\n const isUserFixture = location && filterStackFile(location.file);\n return isUserFixture ? formatLocation(location) : '<builtin>';\n}\n\nexport function fixtureParameterNames(fn: Function | any, location: Location, onError: LoadErrorSink): string[] {\n if (typeof fn !== 'function')\n return [];\n if (!fn[signatureSymbol])\n fn[signatureSymbol] = innerFixtureParameterNames(fn, location, onError);\n return fn[signatureSymbol];\n}\n\nexport function inheritFixtureNames(from: Function, to: Function) {\n (to as any)[signatureSymbol] = (from as any)[signatureSymbol];\n}\n\nfunction innerFixtureParameterNames(fn: Function, location: Location, onError: LoadErrorSink): string[] {\n const text = filterOutComments(fn.toString());\n const match = text.match(/(?:async)?(?:\\s+function)?[^(]*\\(([^)]*)/);\n if (!match)\n return [];\n const trimmedParams = match[1].trim();\n if (!trimmedParams)\n return [];\n const [firstParam] = splitByComma(trimmedParams);\n if (firstParam[0] !== '{' || firstParam[firstParam.length - 1] !== '}') {\n onError({ message: 'First argument must use the object destructuring pattern: ' + firstParam, location });\n return [];\n }\n const props = splitByComma(firstParam.substring(1, firstParam.length - 1)).map(prop => {\n const colon = prop.indexOf(':');\n return colon === -1 ? prop.trim() : prop.substring(0, colon).trim();\n });\n const restProperty = props.find(prop => prop.startsWith('...'));\n if (restProperty) {\n onError({ message: `Rest property \"${restProperty}\" is not supported. List all used fixtures explicitly, separated by comma.`, location });\n return [];\n }\n return props;\n}\n\nfunction filterOutComments(s: string): string {\n const result: string[] = [];\n let commentState: 'none'|'singleline'|'multiline' = 'none';\n for (let i = 0; i < s.length; ++i) {\n if (commentState === 'singleline') {\n if (s[i] === '\\n')\n commentState = 'none';\n } else if (commentState === 'multiline') {\n if (s[i - 1] === '*' && s[i] === '/')\n commentState = 'none';\n } else if (commentState === 'none') {\n if (s[i] === '/' && s[i + 1] === '/') {\n commentState = 'singleline';\n } else if (s[i] === '/' && s[i + 1] === '*') {\n commentState = 'multiline';\n i += 2;\n } else {\n result.push(s[i]);\n }\n }\n }\n return result.join('');\n}\n\nfunction splitByComma(s: string) {\n const result: string[] = [];\n const stack: string[] = [];\n let start = 0;\n for (let i = 0; i < s.length; i++) {\n if (s[i] === '{' || s[i] === '[') {\n stack.push(s[i] === '{' ? '}' : ']');\n } else if (s[i] === stack[stack.length - 1]) {\n stack.pop();\n } else if (!stack.length && s[i] === ',') {\n const token = s.substring(start, i).trim();\n if (token)\n result.push(token);\n start = i + 1;\n }\n }\n const lastToken = s.substring(start).trim();\n if (lastToken)\n result.push(lastToken);\n return result;\n}\n\n// name + superId, fn -> id\nconst registrationIdMap = new Map<string, Map<Function | any, string>>();\nlet lastId = 0;\n\nfunction registrationId(registration: FixtureRegistration): string {\n if (registration.id)\n return registration.id;\n const key = registration.name + '@@@' + (registration.super ? registrationId(registration.super) : '');\n let map = registrationIdMap.get(key);\n if (!map) {\n map = new Map();\n registrationIdMap.set(key, map);\n }\n if (!map.has(registration.fn))\n map.set(registration.fn, String(lastId++));\n registration.id = map.get(registration.fn)!;\n return registration.id;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,oBAAmB;AAEnB,kBAAgD;AAQhD,MAAM,cAA8B,CAAC,QAAQ,QAAQ;AAwCrD,SAAS,eAAe,OAAmC;AACzD,SAAO,MAAM,QAAQ,KAAK,KAAK,OAAO,MAAM,CAAC,MAAM;AACrD;AAEA,SAAS,gBAAgB,OAAmC;AAC1D,SAAO,eAAe,KAAK,KAAK,CAAC,CAAC,MAAM,CAAC,EAAE;AAC7C;AAEO,MAAM,YAAY;AAAA,EAKvB,YAAY,cAAsC,aAA4B,YAA0B,wBAAkC,iBAAmC;AAC3K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C,WAAW,EAAE,CAAC,MAAM,MAAM,MAAM,SAAS,CAAC,GAAG;AAC3C,YAAM,IAAI;AAAA,IACZ,WAAW,CAAC,MAAM,UAAU,EAAE,CAAC,MAAM,KAAK;AACxC,YAAM,QAAQ,EAAE,UAAU,OAAO,CAAC,EAAE,KAAK;AACzC,UAAI;AACF,eAAO,KAAK,KAAK;AACnB,cAAQ,IAAI;AAAA,IACd;AAAA,EACF;AACA,QAAM,YAAY,EAAE,UAAU,KAAK,EAAE,KAAK;AAC1C,MAAI;AACF,WAAO,KAAK,SAAS;AACvB,SAAO;AACT;AAGA,MAAM,oBAAoB,oBAAI,IAAyC;AACvE,IAAI,SAAS;AAEb,SAAS,eAAe,cAA2C;AACjE,MAAI,aAAa;AACf,WAAO,aAAa;AACtB,QAAM,MAAM,aAAa,OAAO,SAAS,aAAa,QAAS,eAAe,aAAa,KAAK,IAAI;AACpG,MAAI,MAAM,kBAAkB,IAAI,GAAG;AACnC,MAAI,CAAC,KAAK;AACR,UAAM,oBAAI,IAAI;AACd,sBAAkB,IAAI,KAAK,GAAG;AAAA,EAChC;AACA,MAAI,CAAC,IAAI,IAAI,aAAa,EAAE;AAC1B,QAAI,IAAI,aAAa,IAAI,OAAO,QAAQ,CAAC;AAC3C,eAAa,KAAK,IAAI,IAAI,aAAa,EAAE;AACzC,SAAO,aAAa;AACtB;",
6
+ "names": ["names", "crypto"]
7
+ }
@@ -0,0 +1,58 @@
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 globals_exports = {};
20
+ __export(globals_exports, {
21
+ currentTestInfo: () => currentTestInfo,
22
+ currentlyLoadingFileSuite: () => currentlyLoadingFileSuite,
23
+ isWorkerProcess: () => isWorkerProcess,
24
+ setCurrentTestInfo: () => setCurrentTestInfo,
25
+ setCurrentlyLoadingFileSuite: () => setCurrentlyLoadingFileSuite,
26
+ setIsWorkerProcess: () => setIsWorkerProcess
27
+ });
28
+ module.exports = __toCommonJS(globals_exports);
29
+ let currentTestInfoValue = null;
30
+ function setCurrentTestInfo(testInfo) {
31
+ currentTestInfoValue = testInfo;
32
+ }
33
+ function currentTestInfo() {
34
+ return currentTestInfoValue;
35
+ }
36
+ let currentFileSuite;
37
+ function setCurrentlyLoadingFileSuite(suite) {
38
+ currentFileSuite = suite;
39
+ }
40
+ function currentlyLoadingFileSuite() {
41
+ return currentFileSuite;
42
+ }
43
+ let _isWorkerProcess = false;
44
+ function setIsWorkerProcess() {
45
+ _isWorkerProcess = true;
46
+ }
47
+ function isWorkerProcess() {
48
+ return _isWorkerProcess;
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ currentTestInfo,
53
+ currentlyLoadingFileSuite,
54
+ isWorkerProcess,
55
+ setCurrentTestInfo,
56
+ setCurrentlyLoadingFileSuite,
57
+ setIsWorkerProcess
58
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/common/globals.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 type { Suite } from './test';\nimport type { TestInfoImpl } from '../worker/testInfo';\n\nlet currentTestInfoValue: TestInfoImpl | null = null;\nexport function setCurrentTestInfo(testInfo: TestInfoImpl | null) {\n currentTestInfoValue = testInfo;\n}\nexport function currentTestInfo(): TestInfoImpl | null {\n return currentTestInfoValue;\n}\n\nlet currentFileSuite: Suite | undefined;\nexport function setCurrentlyLoadingFileSuite(suite: Suite | undefined) {\n currentFileSuite = suite;\n}\nexport function currentlyLoadingFileSuite() {\n return currentFileSuite;\n}\n\nlet _isWorkerProcess = false;\n\nexport function setIsWorkerProcess() {\n _isWorkerProcess = true;\n}\n\nexport function isWorkerProcess() {\n return _isWorkerProcess;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBA,IAAI,uBAA4C;AACzC,SAAS,mBAAmB,UAA+B;AAChE,yBAAuB;AACzB;AACO,SAAS,kBAAuC;AACrD,SAAO;AACT;AAEA,IAAI;AACG,SAAS,6BAA6B,OAA0B;AACrE,qBAAmB;AACrB;AACO,SAAS,4BAA4B;AAC1C,SAAO;AACT;AAEA,IAAI,mBAAmB;AAEhB,SAAS,qBAAqB;AACnC,qBAAmB;AACrB;AAEO,SAAS,kBAAkB;AAChC,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,60 @@
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 ipc_exports = {};
30
+ __export(ipc_exports, {
31
+ serializeConfig: () => serializeConfig,
32
+ stdioChunkToParams: () => stdioChunkToParams
33
+ });
34
+ module.exports = __toCommonJS(ipc_exports);
35
+ var import_util = __toESM(require("util"));
36
+ var import_compilationCache = require("../transform/compilationCache");
37
+ function serializeConfig(config, passCompilationCache) {
38
+ const result = {
39
+ location: { configDir: config.configDir, resolvedConfigFile: config.config.configFile },
40
+ configCLIOverrides: config.configCLIOverrides,
41
+ compilationCache: passCompilationCache ? (0, import_compilationCache.serializeCompilationCache)() : void 0
42
+ };
43
+ try {
44
+ result.metadata = JSON.stringify(config.config.metadata);
45
+ } catch (error) {
46
+ }
47
+ return result;
48
+ }
49
+ function stdioChunkToParams(chunk) {
50
+ if (chunk instanceof Uint8Array)
51
+ return { buffer: Buffer.from(chunk).toString("base64") };
52
+ if (typeof chunk !== "string")
53
+ return { text: import_util.default.inspect(chunk) };
54
+ return { text: chunk };
55
+ }
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ serializeConfig,
59
+ stdioChunkToParams
60
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/common/ipc.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 util from 'util';\n\nimport { serializeCompilationCache } from '../transform/compilationCache';\n\nimport type { ConfigLocation, FullConfigInternal } from './config';\nimport type { ReporterDescription, TestInfoError, TestStatus } from '../../types/test';\nimport type { SerializedCompilationCache } from '../transform/compilationCache';\n\nexport type ConfigCLIOverrides = {\n debug?: boolean;\n failOnFlakyTests?: boolean;\n forbidOnly?: boolean;\n fullyParallel?: boolean;\n globalTimeout?: number;\n maxFailures?: number;\n outputDir?: string;\n preserveOutputDir?: boolean;\n quiet?: boolean;\n repeatEach?: number;\n retries?: number;\n reporter?: ReporterDescription[];\n additionalReporters?: ReporterDescription[];\n shard?: { current: number, total: number };\n timeout?: number;\n tsconfig?: string;\n ignoreSnapshots?: boolean;\n updateSnapshots?: 'all' | 'changed' | 'missing' | 'none';\n updateSourceMethod?: 'overwrite' | 'patch' | '3way';\n workers?: number | string;\n projects?: { name: string, use?: any }[],\n use?: any;\n};\n\nexport type SerializedConfig = {\n location: ConfigLocation;\n configCLIOverrides: ConfigCLIOverrides;\n compilationCache?: SerializedCompilationCache;\n metadata?: string;\n};\n\nexport type ProcessInitParams = {\n timeOrigin: number;\n processName: string;\n};\n\nexport type WorkerInitParams = {\n workerIndex: number;\n parallelIndex: number;\n repeatEachIndex: number;\n projectId: string;\n config: SerializedConfig;\n artifactsDir: string;\n};\n\nexport type TestBeginPayload = {\n testId: string;\n startWallTime: number; // milliseconds since unix epoch\n};\n\nexport type AttachmentPayload = {\n testId: string;\n name: string;\n path?: string;\n body?: string;\n contentType: string;\n stepId?: string;\n};\n\nexport type TestInfoErrorImpl = TestInfoError;\n\nexport type TestEndPayload = {\n testId: string;\n duration: number;\n status: TestStatus;\n errors: TestInfoErrorImpl[];\n hasNonRetriableError: boolean;\n expectedStatus: TestStatus;\n annotations: { type: string, description?: string }[];\n timeout: number;\n};\n\nexport type StepBeginPayload = {\n testId: string;\n stepId: string;\n parentStepId: string | undefined;\n title: string;\n category: string;\n wallTime: number; // milliseconds since unix epoch\n location?: { file: string, line: number, column: number };\n};\n\nexport type StepEndPayload = {\n testId: string;\n stepId: string;\n wallTime: number; // milliseconds since unix epoch\n error?: TestInfoErrorImpl;\n suggestedRebaseline?: string;\n annotations: { type: string, description?: string }[];\n};\n\nexport type TestEntry = {\n testId: string;\n retry: number;\n};\n\nexport type RunPayload = {\n file: string;\n entries: TestEntry[];\n};\n\nexport type DonePayload = {\n fatalErrors: TestInfoErrorImpl[];\n skipTestsDueToSetupFailure: string[]; // test ids\n fatalUnknownTestIds?: string[];\n};\n\nexport type TestOutputPayload = {\n text?: string;\n buffer?: string;\n};\n\nexport type TeardownErrorsPayload = {\n fatalErrors: TestInfoErrorImpl[];\n};\n\nexport type EnvProducedPayload = [string, string | null][];\n\nexport function serializeConfig(config: FullConfigInternal, passCompilationCache: boolean): SerializedConfig {\n const result: SerializedConfig = {\n location: { configDir: config.configDir, resolvedConfigFile: config.config.configFile },\n configCLIOverrides: config.configCLIOverrides,\n compilationCache: passCompilationCache ? serializeCompilationCache() : undefined,\n };\n\n try {\n result.metadata = JSON.stringify(config.config.metadata);\n } catch (error) {}\n\n return result;\n}\n\nexport function stdioChunkToParams(chunk: Uint8Array | string): TestOutputPayload {\n if (chunk instanceof Uint8Array)\n return { buffer: Buffer.from(chunk).toString('base64') };\n if (typeof chunk !== 'string')\n return { text: util.inspect(chunk) };\n return { text: chunk };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,kBAAiB;AAEjB,8BAA0C;AA6HnC,SAAS,gBAAgB,QAA4B,sBAAiD;AAC3G,QAAM,SAA2B;AAAA,IAC/B,UAAU,EAAE,WAAW,OAAO,WAAW,oBAAoB,OAAO,OAAO,WAAW;AAAA,IACtF,oBAAoB,OAAO;AAAA,IAC3B,kBAAkB,2BAAuB,mDAA0B,IAAI;AAAA,EACzE;AAEA,MAAI;AACF,WAAO,WAAW,KAAK,UAAU,OAAO,OAAO,QAAQ;AAAA,EACzD,SAAS,OAAO;AAAA,EAAC;AAEjB,SAAO;AACT;AAEO,SAAS,mBAAmB,OAA+C;AAChF,MAAI,iBAAiB;AACnB,WAAO,EAAE,QAAQ,OAAO,KAAK,KAAK,EAAE,SAAS,QAAQ,EAAE;AACzD,MAAI,OAAO,UAAU;AACnB,WAAO,EAAE,MAAM,YAAAA,QAAK,QAAQ,KAAK,EAAE;AACrC,SAAO,EAAE,MAAM,MAAM;AACvB;",
6
+ "names": ["util"]
7
+ }
@@ -0,0 +1,85 @@
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 poolBuilder_exports = {};
20
+ __export(poolBuilder_exports, {
21
+ PoolBuilder: () => PoolBuilder
22
+ });
23
+ module.exports = __toCommonJS(poolBuilder_exports);
24
+ var import_fixtures = require("./fixtures");
25
+ var import_util = require("../util");
26
+ class PoolBuilder {
27
+ constructor(type, project) {
28
+ this._testTypePools = /* @__PURE__ */ new Map();
29
+ this._type = type;
30
+ this._project = project;
31
+ }
32
+ static createForLoader() {
33
+ return new PoolBuilder("loader");
34
+ }
35
+ static createForWorker(project) {
36
+ return new PoolBuilder("worker", project);
37
+ }
38
+ buildPools(suite, testErrors) {
39
+ suite.forEachTest((test) => {
40
+ const pool = this._buildPoolForTest(test, testErrors);
41
+ if (this._type === "loader")
42
+ test._poolDigest = pool.digest;
43
+ if (this._type === "worker")
44
+ test._pool = pool;
45
+ });
46
+ }
47
+ _buildPoolForTest(test, testErrors) {
48
+ let pool = this._buildTestTypePool(test._testType, testErrors);
49
+ const parents = [];
50
+ for (let parent = test.parent; parent; parent = parent.parent)
51
+ parents.push(parent);
52
+ parents.reverse();
53
+ for (const parent of parents) {
54
+ if (parent._use.length)
55
+ pool = new import_fixtures.FixturePool(parent._use, (e) => this._handleLoadError(e, testErrors), pool, parent._type === "describe");
56
+ for (const hook of parent._hooks)
57
+ pool.validateFunction(hook.fn, hook.type + " hook", hook.location);
58
+ for (const modifier of parent._modifiers)
59
+ pool.validateFunction(modifier.fn, modifier.type + " modifier", modifier.location);
60
+ }
61
+ pool.validateFunction(test.fn, "Test", test.location);
62
+ return pool;
63
+ }
64
+ _buildTestTypePool(testType, testErrors) {
65
+ if (!this._testTypePools.has(testType)) {
66
+ const optionOverrides = {
67
+ overrides: this._project?.project?.use ?? {},
68
+ location: { file: `project#${this._project?.id}`, line: 1, column: 1 }
69
+ };
70
+ const pool = new import_fixtures.FixturePool(testType.fixtures, (e) => this._handleLoadError(e, testErrors), void 0, void 0, optionOverrides);
71
+ this._testTypePools.set(testType, pool);
72
+ }
73
+ return this._testTypePools.get(testType);
74
+ }
75
+ _handleLoadError(e, testErrors) {
76
+ if (testErrors)
77
+ testErrors.push(e);
78
+ else
79
+ throw new Error(`${(0, import_util.formatLocation)(e.location)}: ${e.message}`);
80
+ }
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ PoolBuilder
85
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/common/poolBuilder.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 { FixturePool } from './fixtures';\nimport { formatLocation } from '../util';\n\nimport type { FullProjectInternal } from './config';\nimport type { LoadError } from './fixtures';\nimport type { Suite, TestCase } from './test';\nimport type { TestTypeImpl } from './testType';\nimport type { TestError } from '../../types/testReporter';\n\nexport class PoolBuilder {\n private _project: FullProjectInternal | undefined;\n private _testTypePools = new Map<TestTypeImpl, FixturePool>();\n private _type: 'loader' | 'worker';\n\n static createForLoader() {\n return new PoolBuilder('loader');\n }\n\n static createForWorker(project: FullProjectInternal) {\n return new PoolBuilder('worker', project);\n }\n\n private constructor(type: 'loader' | 'worker', project?: FullProjectInternal) {\n this._type = type;\n this._project = project;\n }\n\n buildPools(suite: Suite, testErrors?: TestError[]) {\n suite.forEachTest(test => {\n const pool = this._buildPoolForTest(test, testErrors);\n if (this._type === 'loader')\n test._poolDigest = pool.digest;\n if (this._type === 'worker')\n test._pool = pool;\n });\n }\n\n private _buildPoolForTest(test: TestCase, testErrors?: TestError[]): FixturePool {\n let pool = this._buildTestTypePool(test._testType, testErrors);\n\n const parents: Suite[] = [];\n for (let parent: Suite | undefined = test.parent; parent; parent = parent.parent)\n parents.push(parent);\n parents.reverse();\n\n for (const parent of parents) {\n if (parent._use.length)\n pool = new FixturePool(parent._use, e => this._handleLoadError(e, testErrors), pool, parent._type === 'describe');\n for (const hook of parent._hooks)\n pool.validateFunction(hook.fn, hook.type + ' hook', hook.location);\n for (const modifier of parent._modifiers)\n pool.validateFunction(modifier.fn, modifier.type + ' modifier', modifier.location);\n }\n\n pool.validateFunction(test.fn, 'Test', test.location);\n return pool;\n }\n\n private _buildTestTypePool(testType: TestTypeImpl, testErrors?: TestError[]): FixturePool {\n if (!this._testTypePools.has(testType)) {\n const optionOverrides = {\n overrides: this._project?.project?.use ?? {},\n location: { file: `project#${this._project?.id}`, line: 1, column: 1 }\n };\n const pool = new FixturePool(testType.fixtures, e => this._handleLoadError(e, testErrors), undefined, undefined, optionOverrides);\n this._testTypePools.set(testType, pool);\n }\n return this._testTypePools.get(testType)!;\n }\n\n private _handleLoadError(e: LoadError, testErrors?: TestError[]): void {\n if (testErrors)\n testErrors.push(e);\n else\n throw new Error(`${formatLocation(e.location)}: ${e.message}`);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,sBAA4B;AAC5B,kBAA+B;AAQxB,MAAM,YAAY;AAAA,EAaf,YAAY,MAA2B,SAA+B;AAX9E,SAAQ,iBAAiB,oBAAI,IAA+B;AAY1D,SAAK,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA,EAXA,OAAO,kBAAkB;AACvB,WAAO,IAAI,YAAY,QAAQ;AAAA,EACjC;AAAA,EAEA,OAAO,gBAAgB,SAA8B;AACnD,WAAO,IAAI,YAAY,UAAU,OAAO;AAAA,EAC1C;AAAA,EAOA,WAAW,OAAc,YAA0B;AACjD,UAAM,YAAY,UAAQ;AACxB,YAAM,OAAO,K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