@smoothdeploy/playwright 1.58.4 → 1.60.0-beta-1780662356000

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 (182) hide show
  1. package/ThirdPartyNotices.txt +8 -5036
  2. package/lib/agents/agentParser.js +2 -2
  3. package/lib/agents/generateAgents.js +21 -22
  4. package/lib/agents/playwright-test-healer.agent.md +1 -0
  5. package/lib/agents/playwright-test-planner.agent.md +2 -1
  6. package/lib/cli/reportActions.js +78 -0
  7. package/lib/cli/testActions.js +211 -0
  8. package/lib/common/index.js +2898 -0
  9. package/lib/common/index.js.txt +35 -0
  10. package/lib/errorContext.js +130 -0
  11. package/lib/index.js +258 -206
  12. package/lib/{isomorphic/testServerConnection.js → isomorphic.js} +70 -35
  13. package/lib/isomorphic.js.txt +9 -0
  14. package/lib/loader/loaderProcessEntry.js +34 -0
  15. package/lib/loader/loaderProcessEntry.js.txt +9 -0
  16. package/lib/matchers/expect.js +12988 -249
  17. package/lib/matchers/expect.js.LICENSE +693 -0
  18. package/lib/matchers/expect.js.txt +72 -0
  19. package/lib/mcp/test/browserBackend.js +49 -22
  20. package/lib/mcp/test/generatorTools.js +16 -16
  21. package/lib/mcp/test/plannerTools.js +25 -20
  22. package/lib/mcp/test/seed.js +7 -7
  23. package/lib/mcp/test/testBackend.js +30 -30
  24. package/lib/mcp/test/testContext.js +50 -33
  25. package/lib/mcp/test/testTools.js +15 -25
  26. package/lib/{internalsForTest.js → package.js} +13 -8
  27. package/lib/program.js +63 -263
  28. package/lib/runner/index.js +8339 -0
  29. package/lib/runner/index.js.txt +60 -0
  30. package/lib/transform/babelBundle.js +71002 -18
  31. package/lib/transform/babelBundle.js.LICENSE +2359 -0
  32. package/lib/transform/babelBundle.js.txt +325 -0
  33. package/lib/transform/esmLoader.js +5884 -30
  34. package/lib/transform/esmLoader.js.LICENSE +335 -0
  35. package/lib/transform/esmLoader.js.txt +55 -0
  36. package/lib/util.js +37 -34
  37. package/lib/worker/workerProcessEntry.js +3251 -0
  38. package/lib/worker/workerProcessEntry.js.txt +24 -0
  39. package/package.json +5 -16
  40. package/test.mjs +1 -0
  41. package/types/test.d.ts +172 -12
  42. package/types/testReporter.d.ts +7 -5
  43. package/lib/common/config.js +0 -282
  44. package/lib/common/configLoader.js +0 -344
  45. package/lib/common/esmLoaderHost.js +0 -104
  46. package/lib/common/expectBundle.js +0 -28
  47. package/lib/common/expectBundleImpl.js +0 -407
  48. package/lib/common/fixtures.js +0 -302
  49. package/lib/common/ipc.js +0 -60
  50. package/lib/common/poolBuilder.js +0 -85
  51. package/lib/common/process.js +0 -132
  52. package/lib/common/suiteUtils.js +0 -140
  53. package/lib/common/test.js +0 -321
  54. package/lib/common/testLoader.js +0 -101
  55. package/lib/common/testType.js +0 -298
  56. package/lib/common/validators.js +0 -68
  57. package/lib/fsWatcher.js +0 -67
  58. package/lib/isomorphic/events.js +0 -77
  59. package/lib/isomorphic/folders.js +0 -30
  60. package/lib/isomorphic/stringInternPool.js +0 -69
  61. package/lib/isomorphic/teleReceiver.js +0 -521
  62. package/lib/isomorphic/teleSuiteUpdater.js +0 -157
  63. package/lib/isomorphic/testServerInterface.js +0 -16
  64. package/lib/isomorphic/testTree.js +0 -329
  65. package/lib/isomorphic/types.d.js +0 -16
  66. package/lib/loader/loaderMain.js +0 -59
  67. package/lib/matchers/matcherHint.js +0 -44
  68. package/lib/matchers/matchers.js +0 -383
  69. package/lib/matchers/toBeTruthy.js +0 -75
  70. package/lib/matchers/toEqual.js +0 -100
  71. package/lib/matchers/toHaveURL.js +0 -101
  72. package/lib/matchers/toMatchAriaSnapshot.js +0 -159
  73. package/lib/matchers/toMatchSnapshot.js +0 -342
  74. package/lib/matchers/toMatchText.js +0 -99
  75. package/lib/mcp/browser/browserContextFactory.js +0 -329
  76. package/lib/mcp/browser/browserServerBackend.js +0 -84
  77. package/lib/mcp/browser/config.js +0 -421
  78. package/lib/mcp/browser/context.js +0 -244
  79. package/lib/mcp/browser/response.js +0 -278
  80. package/lib/mcp/browser/sessionLog.js +0 -75
  81. package/lib/mcp/browser/tab.js +0 -343
  82. package/lib/mcp/browser/tools/common.js +0 -65
  83. package/lib/mcp/browser/tools/console.js +0 -46
  84. package/lib/mcp/browser/tools/dialogs.js +0 -60
  85. package/lib/mcp/browser/tools/evaluate.js +0 -61
  86. package/lib/mcp/browser/tools/files.js +0 -58
  87. package/lib/mcp/browser/tools/form.js +0 -63
  88. package/lib/mcp/browser/tools/install.js +0 -72
  89. package/lib/mcp/browser/tools/keyboard.js +0 -107
  90. package/lib/mcp/browser/tools/mouse.js +0 -107
  91. package/lib/mcp/browser/tools/navigate.js +0 -71
  92. package/lib/mcp/browser/tools/network.js +0 -63
  93. package/lib/mcp/browser/tools/open.js +0 -57
  94. package/lib/mcp/browser/tools/pdf.js +0 -49
  95. package/lib/mcp/browser/tools/runCode.js +0 -78
  96. package/lib/mcp/browser/tools/screenshot.js +0 -93
  97. package/lib/mcp/browser/tools/snapshot.js +0 -173
  98. package/lib/mcp/browser/tools/tabs.js +0 -67
  99. package/lib/mcp/browser/tools/tool.js +0 -47
  100. package/lib/mcp/browser/tools/tracing.js +0 -74
  101. package/lib/mcp/browser/tools/utils.js +0 -94
  102. package/lib/mcp/browser/tools/verify.js +0 -143
  103. package/lib/mcp/browser/tools/wait.js +0 -63
  104. package/lib/mcp/browser/tools.js +0 -84
  105. package/lib/mcp/browser/watchdog.js +0 -44
  106. package/lib/mcp/config.d.js +0 -16
  107. package/lib/mcp/extension/cdpRelay.js +0 -351
  108. package/lib/mcp/extension/extensionContextFactory.js +0 -76
  109. package/lib/mcp/extension/protocol.js +0 -28
  110. package/lib/mcp/index.js +0 -61
  111. package/lib/mcp/log.js +0 -35
  112. package/lib/mcp/program.js +0 -111
  113. package/lib/mcp/sdk/exports.js +0 -28
  114. package/lib/mcp/sdk/http.js +0 -152
  115. package/lib/mcp/sdk/inProcessTransport.js +0 -71
  116. package/lib/mcp/sdk/server.js +0 -223
  117. package/lib/mcp/sdk/tool.js +0 -47
  118. package/lib/mcp/terminal/cli.js +0 -296
  119. package/lib/mcp/terminal/command.js +0 -56
  120. package/lib/mcp/terminal/commands.js +0 -333
  121. package/lib/mcp/terminal/daemon.js +0 -129
  122. package/lib/mcp/terminal/help.json +0 -32
  123. package/lib/mcp/terminal/helpGenerator.js +0 -88
  124. package/lib/mcp/terminal/socketConnection.js +0 -80
  125. package/lib/plugins/gitCommitInfoPlugin.js +0 -198
  126. package/lib/plugins/index.js +0 -28
  127. package/lib/plugins/webServerPlugin.js +0 -237
  128. package/lib/reporters/base.js +0 -634
  129. package/lib/reporters/blob.js +0 -138
  130. package/lib/reporters/dot.js +0 -99
  131. package/lib/reporters/empty.js +0 -32
  132. package/lib/reporters/github.js +0 -128
  133. package/lib/reporters/html.js +0 -633
  134. package/lib/reporters/internalReporter.js +0 -138
  135. package/lib/reporters/json.js +0 -254
  136. package/lib/reporters/junit.js +0 -232
  137. package/lib/reporters/line.js +0 -131
  138. package/lib/reporters/list.js +0 -253
  139. package/lib/reporters/listModeReporter.js +0 -69
  140. package/lib/reporters/markdown.js +0 -144
  141. package/lib/reporters/merge.js +0 -558
  142. package/lib/reporters/multiplexer.js +0 -112
  143. package/lib/reporters/reporterV2.js +0 -102
  144. package/lib/reporters/smoothdeploy.js +0 -333
  145. package/lib/reporters/teleEmitter.js +0 -317
  146. package/lib/reporters/versions/blobV1.js +0 -16
  147. package/lib/runner/dispatcher.js +0 -531
  148. package/lib/runner/failureTracker.js +0 -72
  149. package/lib/runner/lastRun.js +0 -77
  150. package/lib/runner/loadUtils.js +0 -334
  151. package/lib/runner/loaderHost.js +0 -89
  152. package/lib/runner/processHost.js +0 -180
  153. package/lib/runner/projectUtils.js +0 -241
  154. package/lib/runner/rebase.js +0 -189
  155. package/lib/runner/reporters.js +0 -140
  156. package/lib/runner/sigIntWatcher.js +0 -96
  157. package/lib/runner/storage.js +0 -91
  158. package/lib/runner/taskRunner.js +0 -127
  159. package/lib/runner/tasks.js +0 -410
  160. package/lib/runner/testGroups.js +0 -125
  161. package/lib/runner/testRunner.js +0 -398
  162. package/lib/runner/testServer.js +0 -269
  163. package/lib/runner/uiModeReporter.js +0 -30
  164. package/lib/runner/vcs.js +0 -72
  165. package/lib/runner/watchMode.js +0 -396
  166. package/lib/runner/workerHost.js +0 -104
  167. package/lib/third_party/pirates.js +0 -62
  168. package/lib/third_party/tsconfig-loader.js +0 -103
  169. package/lib/transform/babelBundleImpl.js +0 -461
  170. package/lib/transform/compilationCache.js +0 -274
  171. package/lib/transform/md.js +0 -221
  172. package/lib/transform/portTransport.js +0 -67
  173. package/lib/transform/transform.js +0 -303
  174. package/lib/utilsBundle.js +0 -50
  175. package/lib/utilsBundleImpl.js +0 -103
  176. package/lib/worker/fixtureRunner.js +0 -262
  177. package/lib/worker/testInfo.js +0 -536
  178. package/lib/worker/testTracing.js +0 -345
  179. package/lib/worker/timeoutManager.js +0 -174
  180. package/lib/worker/util.js +0 -31
  181. package/lib/worker/workerMain.js +0 -530
  182. /package/lib/{common/globals.js → globals.js} +0 -0
@@ -1,125 +0,0 @@
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 testGroups_exports = {};
20
- __export(testGroups_exports, {
21
- createTestGroups: () => createTestGroups,
22
- filterForShard: () => filterForShard
23
- });
24
- module.exports = __toCommonJS(testGroups_exports);
25
- function createTestGroups(projectSuite, expectedParallelism) {
26
- const groups = /* @__PURE__ */ new Map();
27
- const createGroup = (test) => {
28
- return {
29
- workerHash: test._workerHash,
30
- requireFile: test._requireFile,
31
- repeatEachIndex: test.repeatEachIndex,
32
- projectId: test._projectId,
33
- tests: []
34
- };
35
- };
36
- for (const test of projectSuite.allTests()) {
37
- let withWorkerHash = groups.get(test._workerHash);
38
- if (!withWorkerHash) {
39
- withWorkerHash = /* @__PURE__ */ new Map();
40
- groups.set(test._workerHash, withWorkerHash);
41
- }
42
- let withRequireFile = withWorkerHash.get(test._requireFile);
43
- if (!withRequireFile) {
44
- withRequireFile = {
45
- general: createGroup(test),
46
- parallel: /* @__PURE__ */ new Map(),
47
- parallelWithHooks: createGroup(test)
48
- };
49
- withWorkerHash.set(test._requireFile, withRequireFile);
50
- }
51
- let insideParallel = false;
52
- let outerMostSequentialSuite;
53
- let hasAllHooks = false;
54
- for (let parent = test.parent; parent; parent = parent.parent) {
55
- if (parent._parallelMode === "serial" || parent._parallelMode === "default")
56
- outerMostSequentialSuite = parent;
57
- insideParallel = insideParallel || parent._parallelMode === "parallel";
58
- hasAllHooks = hasAllHooks || parent._hooks.some((hook) => hook.type === "beforeAll" || hook.type === "afterAll");
59
- }
60
- if (insideParallel) {
61
- if (hasAllHooks && !outerMostSequentialSuite) {
62
- withRequireFile.parallelWithHooks.tests.push(test);
63
- } else {
64
- const key = outerMostSequentialSuite || test;
65
- let group = withRequireFile.parallel.get(key);
66
- if (!group) {
67
- group = createGroup(test);
68
- withRequireFile.parallel.set(key, group);
69
- }
70
- group.tests.push(test);
71
- }
72
- } else {
73
- withRequireFile.general.tests.push(test);
74
- }
75
- }
76
- const result = [];
77
- for (const withWorkerHash of groups.values()) {
78
- for (const withRequireFile of withWorkerHash.values()) {
79
- if (withRequireFile.general.tests.length)
80
- result.push(withRequireFile.general);
81
- result.push(...withRequireFile.parallel.values());
82
- const parallelWithHooksGroupSize = Math.ceil(withRequireFile.parallelWithHooks.tests.length / expectedParallelism);
83
- let lastGroup;
84
- for (const test of withRequireFile.parallelWithHooks.tests) {
85
- if (!lastGroup || lastGroup.tests.length >= parallelWithHooksGroupSize) {
86
- lastGroup = createGroup(test);
87
- result.push(lastGroup);
88
- }
89
- lastGroup.tests.push(test);
90
- }
91
- }
92
- }
93
- return result;
94
- }
95
- function filterForShard(shard, weights, testGroups) {
96
- weights ??= Array.from({ length: shard.total }, () => 1);
97
- if (weights.length !== shard.total)
98
- throw new Error(`PWTEST_SHARD_WEIGHTS number of weights must match the shard total of ${shard.total}`);
99
- const totalWeight = weights.reduce((a, b) => a + b, 0);
100
- let shardableTotal = 0;
101
- for (const group of testGroups)
102
- shardableTotal += group.tests.length;
103
- const shardSizes = weights.map((w) => Math.floor(w * shardableTotal / totalWeight));
104
- const remainder = shardableTotal - shardSizes.reduce((a, b) => a + b, 0);
105
- for (let i = 0; i < remainder; i++) {
106
- shardSizes[i % shardSizes.length]++;
107
- }
108
- let from = 0;
109
- for (let i = 0; i < shard.current - 1; i++)
110
- from += shardSizes[i];
111
- const to = from + shardSizes[shard.current - 1];
112
- let current = 0;
113
- const result = /* @__PURE__ */ new Set();
114
- for (const group of testGroups) {
115
- if (current >= from && current < to)
116
- result.add(group);
117
- current += group.tests.length;
118
- }
119
- return result;
120
- }
121
- // Annotate the CommonJS export names for ESM import in node:
122
- 0 && (module.exports = {
123
- createTestGroups,
124
- filterForShard
125
- });
@@ -1,398 +0,0 @@
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 testRunner_exports = {};
30
- __export(testRunner_exports, {
31
- TestRunner: () => TestRunner,
32
- TestRunnerEvent: () => TestRunnerEvent,
33
- runAllTestsWithConfig: () => runAllTestsWithConfig
34
- });
35
- module.exports = __toCommonJS(testRunner_exports);
36
- var import_events = __toESM(require("events"));
37
- var import_fs = __toESM(require("fs"));
38
- var import_path = __toESM(require("path"));
39
- var import_server = require("playwright-core/lib/server");
40
- var import_utils = require("playwright-core/lib/utils");
41
- var import_configLoader = require("../common/configLoader");
42
- var import_fsWatcher = require("../fsWatcher");
43
- var import_teleReceiver = require("../isomorphic/teleReceiver");
44
- var import_gitCommitInfoPlugin = require("../plugins/gitCommitInfoPlugin");
45
- var import_webServerPlugin = require("../plugins/webServerPlugin");
46
- var import_base = require("../reporters/base");
47
- var import_internalReporter = require("../reporters/internalReporter");
48
- var import_compilationCache = require("../transform/compilationCache");
49
- var import_util = require("../util");
50
- var import_reporters = require("./reporters");
51
- var import_tasks = require("./tasks");
52
- var import_lastRun = require("./lastRun");
53
- const TestRunnerEvent = {
54
- TestFilesChanged: "testFilesChanged",
55
- TestPaused: "testPaused"
56
- };
57
- class TestRunner extends import_events.default {
58
- constructor(configLocation, configCLIOverrides) {
59
- super();
60
- this._watchedProjectDirs = /* @__PURE__ */ new Set();
61
- this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
62
- this._watchedTestDependencies = /* @__PURE__ */ new Set();
63
- this._queue = Promise.resolve();
64
- this._watchTestDirs = false;
65
- this._populateDependenciesOnList = false;
66
- this._startingEnv = {};
67
- this.configLocation = configLocation;
68
- this._configCLIOverrides = configCLIOverrides;
69
- this._watcher = new import_fsWatcher.Watcher((events) => {
70
- const collector = /* @__PURE__ */ new Set();
71
- events.forEach((f) => (0, import_compilationCache.collectAffectedTestFiles)(f.file, collector));
72
- this.emit(TestRunnerEvent.TestFilesChanged, [...collector]);
73
- });
74
- }
75
- async initialize(params) {
76
- (0, import_utils.setPlaywrightTestProcessEnv)();
77
- this._watchTestDirs = !!params.watchTestDirs;
78
- this._populateDependenciesOnList = !!params.populateDependenciesOnList;
79
- this._startingEnv = { ...process.env };
80
- }
81
- resizeTerminal(params) {
82
- process.stdout.columns = params.cols;
83
- process.stdout.rows = params.rows;
84
- process.stderr.columns = params.cols;
85
- process.stderr.rows = params.rows;
86
- }
87
- hasSomeBrowsers() {
88
- for (const browserName of ["chromium", "webkit", "firefox"]) {
89
- try {
90
- import_server.registry.findExecutable(browserName).executablePathOrDie("javascript");
91
- return true;
92
- } catch {
93
- }
94
- }
95
- return false;
96
- }
97
- async installBrowsers() {
98
- const executables = import_server.registry.defaultExecutables();
99
- await import_server.registry.install(executables);
100
- }
101
- async loadConfig() {
102
- const { config, error } = await this._loadConfig(this._configCLIOverrides);
103
- if (config)
104
- return config;
105
- throw new Error("Failed to load config: " + (error ? error.message : "Unknown error"));
106
- }
107
- async runGlobalSetup(userReporters) {
108
- await this.runGlobalTeardown();
109
- const reporter = new import_internalReporter.InternalReporter(userReporters);
110
- const config = await this._loadConfigOrReportError(reporter, this._configCLIOverrides);
111
- if (!config)
112
- return { status: "failed", env: [] };
113
- const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
114
- ...(0, import_tasks.createGlobalSetupTasks)(config)
115
- ]);
116
- const env = [];
117
- for (const key of /* @__PURE__ */ new Set([...Object.keys(process.env), ...Object.keys(this._startingEnv)])) {
118
- if (this._startingEnv[key] !== process.env[key])
119
- env.push([key, process.env[key] ?? null]);
120
- }
121
- if (status !== "passed")
122
- await cleanup();
123
- else
124
- this._globalSetup = { cleanup };
125
- return { status, env };
126
- }
127
- async runGlobalTeardown() {
128
- const globalSetup = this._globalSetup;
129
- const status = await globalSetup?.cleanup();
130
- this._globalSetup = void 0;
131
- return { status };
132
- }
133
- async startDevServer(userReporter, mode) {
134
- await this.stopDevServer();
135
- const reporter = new import_internalReporter.InternalReporter([userReporter]);
136
- const config = await this._loadConfigOrReportError(reporter);
137
- if (!config)
138
- return { status: "failed" };
139
- const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
140
- ...(0, import_tasks.createPluginSetupTasks)(config),
141
- (0, import_tasks.createLoadTask)(mode, { failOnLoadErrors: true, filterOnly: false }),
142
- (0, import_tasks.createStartDevServerTask)()
143
- ]);
144
- if (status !== "passed")
145
- await cleanup();
146
- else
147
- this._devServer = { cleanup };
148
- return { status };
149
- }
150
- async stopDevServer() {
151
- const devServer = this._devServer;
152
- const status = await devServer?.cleanup();
153
- this._devServer = void 0;
154
- return { status };
155
- }
156
- async clearCache(userReporter) {
157
- const reporter = new import_internalReporter.InternalReporter(userReporter ? [userReporter] : []);
158
- const config = await this._loadConfigOrReportError(reporter);
159
- if (!config)
160
- return { status: "failed" };
161
- const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
162
- ...(0, import_tasks.createPluginSetupTasks)(config),
163
- (0, import_tasks.createClearCacheTask)(config)
164
- ]);
165
- return { status };
166
- }
167
- async listFiles(userReporter, projects) {
168
- const reporter = new import_internalReporter.InternalReporter([userReporter]);
169
- const config = await this._loadConfigOrReportError(reporter);
170
- if (!config)
171
- return { status: "failed" };
172
- config.cliProjectFilter = projects?.length ? projects : void 0;
173
- const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
174
- (0, import_tasks.createListFilesTask)(),
175
- (0, import_tasks.createReportBeginTask)()
176
- ]);
177
- return { status };
178
- }
179
- async listTests(userReporter, params) {
180
- let result;
181
- this._queue = this._queue.then(async () => {
182
- const { config, status } = await this._innerListTests(userReporter, params);
183
- if (config)
184
- await this._updateWatchedDirs(config);
185
- result = { status };
186
- }).catch(printInternalError);
187
- await this._queue;
188
- return result;
189
- }
190
- async _innerListTests(userReporter, params) {
191
- const overrides = {
192
- ...this._configCLIOverrides,
193
- repeatEach: 1,
194
- retries: 0
195
- };
196
- const reporter = new import_internalReporter.InternalReporter([userReporter]);
197
- const config = await this._loadConfigOrReportError(reporter, overrides);
198
- if (!config)
199
- return { status: "failed" };
200
- config.cliArgs = params.locations || [];
201
- config.cliGrep = params.grep;
202
- config.cliGrepInvert = params.grepInvert;
203
- config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
204
- config.cliListOnly = true;
205
- const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
206
- (0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
207
- (0, import_tasks.createReportBeginTask)()
208
- ]);
209
- return { config, status };
210
- }
211
- async _updateWatchedDirs(config) {
212
- this._watchedProjectDirs = /* @__PURE__ */ new Set();
213
- this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
214
- for (const p of config.projects) {
215
- this._watchedProjectDirs.add(p.project.testDir);
216
- this._ignoredProjectOutputs.add(p.project.outputDir);
217
- }
218
- const result = await resolveCtDirs(config);
219
- if (result) {
220
- this._watchedProjectDirs.add(result.templateDir);
221
- this._ignoredProjectOutputs.add(result.outDir);
222
- }
223
- if (this._watchTestDirs)
224
- await this._updateWatcher(false);
225
- }
226
- async _updateWatcher(reportPending) {
227
- await this._watcher.update([...this._watchedProjectDirs, ...this._watchedTestDependencies], [...this._ignoredProjectOutputs], reportPending);
228
- }
229
- async runTests(userReporter, params) {
230
- let result = { status: "passed" };
231
- this._queue = this._queue.then(async () => {
232
- result = await this._innerRunTests(userReporter, params).catch((e) => {
233
- printInternalError(e);
234
- return { status: "failed" };
235
- });
236
- });
237
- await this._queue;
238
- return result;
239
- }
240
- async _innerRunTests(userReporter, params) {
241
- await this.stopTests();
242
- const overrides = {
243
- ...this._configCLIOverrides,
244
- repeatEach: 1,
245
- retries: 0,
246
- timeout: params.timeout,
247
- preserveOutputDir: true,
248
- reporter: params.reporters ? params.reporters.map((r) => [r]) : void 0,
249
- use: {
250
- ...this._configCLIOverrides.use,
251
- ...params.trace === "on" ? { trace: { mode: "on", sources: false, _live: true } } : {},
252
- ...params.trace === "off" ? { trace: "off" } : {},
253
- ...params.video === "on" || params.video === "off" ? { video: params.video } : {},
254
- ...params.headed !== void 0 ? { headless: !params.headed } : {},
255
- _optionContextReuseMode: params.reuseContext ? "when-possible" : void 0,
256
- _optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : void 0,
257
- actionTimeout: params.actionTimeout
258
- },
259
- ...params.updateSnapshots ? { updateSnapshots: params.updateSnapshots } : {},
260
- ...params.updateSourceMethod ? { updateSourceMethod: params.updateSourceMethod } : {},
261
- ...params.runAgents ? { runAgents: params.runAgents } : {},
262
- ...params.workers ? { workers: params.workers } : {}
263
- };
264
- const config = await this._loadConfigOrReportError(new import_internalReporter.InternalReporter([userReporter]), overrides);
265
- if (!config)
266
- return { status: "failed" };
267
- config.cliListOnly = false;
268
- config.cliPassWithNoTests = true;
269
- config.cliArgs = params.locations;
270
- config.cliGrep = params.grep;
271
- config.cliGrepInvert = params.grepInvert;
272
- config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
273
- config.preOnlyTestFilters = [];
274
- if (params.testIds) {
275
- const testIdSet = new Set(params.testIds);
276
- config.preOnlyTestFilters.push((test) => testIdSet.has(test.id));
277
- }
278
- const configReporters = params.disableConfigReporters ? [] : await (0, import_reporters.createReporters)(config, "test");
279
- const reporter = new import_internalReporter.InternalReporter([...configReporters, userReporter]);
280
- const stop = new import_utils.ManualPromise();
281
- const tasks = [
282
- (0, import_tasks.createApplyRebaselinesTask)(),
283
- (0, import_tasks.createLoadTask)("out-of-process", { filterOnly: true, failOnLoadErrors: !!params.failOnLoadErrors, doNotRunDepsOutsideProjectFilter: params.doNotRunDepsOutsideProjectFilter }),
284
- ...(0, import_tasks.createRunTestsTasks)(config)
285
- ];
286
- const testRun = new import_tasks.TestRun(config, reporter, { pauseOnError: params.pauseOnError, pauseAtEnd: params.pauseAtEnd });
287
- testRun.failureTracker.onTestPaused = (params2) => this.emit(TestRunnerEvent.TestPaused, params2);
288
- const run = (0, import_tasks.runTasks)(testRun, tasks, 0, stop).then(async (status) => {
289
- this._testRun = void 0;
290
- return status;
291
- });
292
- this._testRun = { run, stop };
293
- return { status: await run };
294
- }
295
- async watch(fileNames) {
296
- this._watchedTestDependencies = /* @__PURE__ */ new Set();
297
- for (const fileName of fileNames) {
298
- this._watchedTestDependencies.add(fileName);
299
- (0, import_compilationCache.dependenciesForTestFile)(fileName).forEach((file) => this._watchedTestDependencies.add(file));
300
- }
301
- await this._updateWatcher(true);
302
- }
303
- async findRelatedTestFiles(files, userReporter) {
304
- const errorReporter = (0, import_reporters.createErrorCollectingReporter)(import_base.internalScreen);
305
- const reporter = new import_internalReporter.InternalReporter(userReporter ? [userReporter, errorReporter] : [errorReporter]);
306
- const config = await this._loadConfigOrReportError(reporter);
307
- if (!config)
308
- return { errors: errorReporter.errors(), testFiles: [] };
309
- const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
310
- ...(0, import_tasks.createPluginSetupTasks)(config),
311
- (0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false, populateDependencies: true })
312
- ]);
313
- if (status !== "passed")
314
- return { errors: errorReporter.errors(), testFiles: [] };
315
- return { testFiles: (0, import_compilationCache.affectedTestFiles)(files) };
316
- }
317
- async stopTests() {
318
- this._testRun?.stop?.resolve();
319
- await this._testRun?.run;
320
- }
321
- async closeGracefully() {
322
- (0, import_utils.gracefullyProcessExitDoNotHang)(0);
323
- }
324
- async stop() {
325
- await this.runGlobalTeardown();
326
- }
327
- async _loadConfig(overrides) {
328
- try {
329
- const config = await (0, import_configLoader.loadConfig)(this.configLocation, overrides);
330
- if (!this._plugins) {
331
- (0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
332
- (0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
333
- this._plugins = config.plugins || [];
334
- } else {
335
- config.plugins.splice(0, config.plugins.length, ...this._plugins);
336
- }
337
- return { config };
338
- } catch (e) {
339
- return { config: null, error: (0, import_util.serializeError)(e) };
340
- }
341
- }
342
- async _loadConfigOrReportError(reporter, overrides) {
343
- const { config, error } = await this._loadConfig(overrides);
344
- if (config)
345
- return config;
346
- reporter.onConfigure(import_teleReceiver.baseFullConfig);
347
- reporter.onError(error);
348
- await reporter.onEnd({ status: "failed" });
349
- await reporter.onExit();
350
- return null;
351
- }
352
- }
353
- function printInternalError(e) {
354
- console.error("Internal error:", e);
355
- }
356
- async function resolveCtDirs(config) {
357
- const use = config.config.projects[0].use;
358
- const relativeTemplateDir = use.ctTemplateDir || "playwright";
359
- const templateDir = await import_fs.default.promises.realpath(import_path.default.normalize(import_path.default.join(config.configDir, relativeTemplateDir))).catch(() => void 0);
360
- if (!templateDir)
361
- return null;
362
- const outDir = use.ctCacheDir ? import_path.default.resolve(config.configDir, use.ctCacheDir) : import_path.default.resolve(templateDir, ".cache");
363
- return {
364
- outDir,
365
- templateDir
366
- };
367
- }
368
- async function runAllTestsWithConfig(config) {
369
- (0, import_utils.setPlaywrightTestProcessEnv)();
370
- const listOnly = config.cliListOnly;
371
- (0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
372
- (0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
373
- const reporters = await (0, import_reporters.createReporters)(config, listOnly ? "list" : "test");
374
- const lastRun = new import_lastRun.LastRunReporter(config);
375
- if (config.cliLastFailed)
376
- await lastRun.filterLastFailed();
377
- const reporter = new import_internalReporter.InternalReporter([...reporters, lastRun]);
378
- const tasks = listOnly ? [
379
- (0, import_tasks.createLoadTask)("in-process", { failOnLoadErrors: true, filterOnly: false }),
380
- (0, import_tasks.createReportBeginTask)()
381
- ] : [
382
- (0, import_tasks.createApplyRebaselinesTask)(),
383
- ...(0, import_tasks.createGlobalSetupTasks)(config),
384
- (0, import_tasks.createLoadTask)("in-process", { filterOnly: true, failOnLoadErrors: true }),
385
- ...(0, import_tasks.createRunTestsTasks)(config)
386
- ];
387
- const testRun = new import_tasks.TestRun(config, reporter, { pauseAtEnd: config.configCLIOverrides.pause, pauseOnError: config.configCLIOverrides.pause });
388
- const status = await (0, import_tasks.runTasks)(testRun, tasks, config.config.globalTimeout);
389
- await new Promise((resolve) => process.stdout.write("", () => resolve()));
390
- await new Promise((resolve) => process.stderr.write("", () => resolve()));
391
- return status;
392
- }
393
- // Annotate the CommonJS export names for ESM import in node:
394
- 0 && (module.exports = {
395
- TestRunner,
396
- TestRunnerEvent,
397
- runAllTestsWithConfig
398
- });