playwright 1.55.0-alpha-2025-08-13 → 1.55.0-alpha-2025-08-15

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.

Potentially problematic release.


This version of playwright might be problematic. Click here for more details.

@@ -0,0 +1,66 @@
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 listModeReporter_exports = {};
30
+ __export(listModeReporter_exports, {
31
+ default: () => listModeReporter_default
32
+ });
33
+ module.exports = __toCommonJS(listModeReporter_exports);
34
+ var import_path = __toESM(require("path"));
35
+ var import_base = require("./base");
36
+ class ListModeReporter {
37
+ constructor(options) {
38
+ this.screen = options?.screen ?? import_base.terminalScreen;
39
+ }
40
+ version() {
41
+ return "v2";
42
+ }
43
+ onConfigure(config) {
44
+ this.config = config;
45
+ }
46
+ onBegin(suite) {
47
+ this._writeLine(`Listing tests:`);
48
+ const tests = suite.allTests();
49
+ const files = /* @__PURE__ */ new Set();
50
+ for (const test of tests) {
51
+ const [, projectName, , ...titles] = test.titlePath();
52
+ const location = `${import_path.default.relative(this.config.rootDir, test.location.file)}:${test.location.line}:${test.location.column}`;
53
+ const projectTitle = projectName ? `[${projectName}] \u203A ` : "";
54
+ this._writeLine(` ${projectTitle}${location} \u203A ${titles.join(" \u203A ")}`);
55
+ files.add(test.location.file);
56
+ }
57
+ this._writeLine(`Total: ${tests.length} ${tests.length === 1 ? "test" : "tests"} in ${files.size} ${files.size === 1 ? "file" : "files"}`);
58
+ }
59
+ onError(error) {
60
+ this.screen.stderr.write("\n" + (0, import_base.formatError)(import_base.terminalScreen, error).message + "\n");
61
+ }
62
+ _writeLine(line) {
63
+ this.screen.stdout.write(line + "\n");
64
+ }
65
+ }
66
+ var listModeReporter_default = ListModeReporter;
@@ -74,7 +74,6 @@ class MarkdownReporter {
74
74
  const skipped = summary.skipped ? `, ${summary.skipped} skipped` : "";
75
75
  const didNotRun = summary.didNotRun ? `, ${summary.didNotRun} did not run` : "";
76
76
  lines.push(`**${summary.expected} passed${skipped}${didNotRun}**`);
77
- lines.push(`:heavy_check_mark::heavy_check_mark::heavy_check_mark:`);
78
77
  lines.push(``);
79
78
  await this.publishReport(lines.join("\n"));
80
79
  }
@@ -135,10 +134,11 @@ class MarkdownReporter {
135
134
  function formatTestTitle(rootDir, test) {
136
135
  const [, projectName, , ...titles] = test.titlePath();
137
136
  const relativeTestPath = import_path.default.relative(rootDir, test.location.file);
138
- const location = `${relativeTestPath}:${test.location.line}:${test.location.column}`;
137
+ const location = `${relativeTestPath}:\u200B${test.location.line}:${test.location.column}`;
139
138
  const projectTitle = projectName ? `[${projectName}] \u203A ` : "";
140
139
  const testTitle = `${projectTitle}${location} \u203A ${titles.join(" \u203A ")}`;
141
140
  const extraTags = test.tags.filter((t) => !testTitle.includes(t));
142
- return `${testTitle}${extraTags.length ? " " + extraTags.join(" ") : ""}`;
141
+ const formattedTags = extraTags.map((t) => `\`${t}\``).join(" ");
142
+ return `${testTitle}${extraTags.length ? " " + formattedTags : ""}`;
143
143
  }
144
144
  var markdown_default = MarkdownReporter;
@@ -158,7 +158,8 @@ class Dispatcher {
158
158
  _createWorker(testGroup, parallelIndex, loaderData) {
159
159
  const projectConfig = this._config.projects.find((p) => p.id === testGroup.projectId);
160
160
  const outputDir = projectConfig.project.outputDir;
161
- const worker = new import_workerHost.WorkerHost(testGroup, parallelIndex, loaderData, this._extraEnvByProjectId.get(testGroup.projectId) || {}, outputDir);
161
+ const recoverFromStepErrors = this._failureTracker.canRecoverFromStepError();
162
+ const worker = new import_workerHost.WorkerHost(testGroup, parallelIndex, loaderData, recoverFromStepErrors, this._extraEnvByProjectId.get(testGroup.projectId) || {}, outputDir);
162
163
  const handleOutput = (params) => {
163
164
  const chunk = chunkFromParams(params);
164
165
  if (worker.didFail()) {
@@ -311,6 +312,24 @@ class JobDispatcher {
311
312
  steps.delete(params.stepId);
312
313
  this._reporter.onStepEnd?.(test, result, step);
313
314
  }
315
+ _onStepRecoverFromError(resumeAfterStepError, params) {
316
+ const data = this._dataByTestId.get(params.testId);
317
+ if (!data) {
318
+ resumeAfterStepError({ stepId: params.stepId, status: "failed" });
319
+ return;
320
+ }
321
+ const { steps } = data;
322
+ const step = steps.get(params.stepId);
323
+ if (!step) {
324
+ resumeAfterStepError({ stepId: params.stepId, status: "failed" });
325
+ return;
326
+ }
327
+ const testError = {
328
+ ...params.error,
329
+ location: step.location
330
+ };
331
+ this._failureTracker.recoverFromStepError(params.stepId, testError, resumeAfterStepError);
332
+ }
314
333
  _onAttach(params) {
315
334
  const data = this._dataByTestId.get(params.testId);
316
335
  if (!data) {
@@ -436,11 +455,13 @@ class JobDispatcher {
436
455
  })
437
456
  };
438
457
  worker.runTestGroup(runPayload);
458
+ const resumeAfterStepError = worker.resumeAfterStepError.bind(worker);
439
459
  this._listeners = [
440
460
  import_utils.eventsHelper.addEventListener(worker, "testBegin", this._onTestBegin.bind(this)),
441
461
  import_utils.eventsHelper.addEventListener(worker, "testEnd", this._onTestEnd.bind(this)),
442
462
  import_utils.eventsHelper.addEventListener(worker, "stepBegin", this._onStepBegin.bind(this)),
443
463
  import_utils.eventsHelper.addEventListener(worker, "stepEnd", this._onStepEnd.bind(this)),
464
+ import_utils.eventsHelper.addEventListener(worker, "stepRecoverFromError", this._onStepRecoverFromError.bind(this, resumeAfterStepError)),
444
465
  import_utils.eventsHelper.addEventListener(worker, "attach", this._onAttach.bind(this)),
445
466
  import_utils.eventsHelper.addEventListener(worker, "done", this._onDone.bind(this)),
446
467
  import_utils.eventsHelper.addEventListener(worker, "exit", this.onExit.bind(this))
@@ -27,6 +27,12 @@ class FailureTracker {
27
27
  this._failureCount = 0;
28
28
  this._hasWorkerErrors = false;
29
29
  }
30
+ canRecoverFromStepError() {
31
+ return !!this._recoverFromStepErrorHandler;
32
+ }
33
+ setRecoverFromStepErrorHandler(recoverFromStepErrorHandler) {
34
+ this._recoverFromStepErrorHandler = recoverFromStepErrorHandler;
35
+ }
30
36
  onRootSuite(rootSuite) {
31
37
  this._rootSuite = rootSuite;
32
38
  }
@@ -34,6 +40,14 @@ class FailureTracker {
34
40
  if (test.outcome() === "unexpected" && test.results.length > test.retries)
35
41
  ++this._failureCount;
36
42
  }
43
+ recoverFromStepError(stepId, error, resumeAfterStepError) {
44
+ if (!this._recoverFromStepErrorHandler) {
45
+ resumeAfterStepError({ stepId, status: "failed" });
46
+ return;
47
+ }
48
+ void this._recoverFromStepErrorHandler(stepId, error).then(resumeAfterStepError).catch(() => {
49
+ });
50
+ }
37
51
  onWorkerError() {
38
52
  this._hasWorkerErrors = true;
39
53
  }
@@ -33,7 +33,6 @@ __export(reporters_exports, {
33
33
  createReporters: () => createReporters
34
34
  });
35
35
  module.exports = __toCommonJS(reporters_exports);
36
- var import_path = __toESM(require("path"));
37
36
  var import_utils = require("playwright-core/lib/utils");
38
37
  var import_loadUtils = require("./loadUtils");
39
38
  var import_base = require("../reporters/base");
@@ -46,13 +45,14 @@ var import_json = __toESM(require("../reporters/json"));
46
45
  var import_junit = __toESM(require("../reporters/junit"));
47
46
  var import_line = __toESM(require("../reporters/line"));
48
47
  var import_list = __toESM(require("../reporters/list"));
48
+ var import_listModeReporter = __toESM(require("../reporters/listModeReporter"));
49
49
  var import_reporterV2 = require("../reporters/reporterV2");
50
50
  async function createReporters(config, mode, isTestServer, descriptions) {
51
51
  const defaultReporters = {
52
52
  blob: import_blob.BlobReporter,
53
- dot: mode === "list" ? ListModeReporter : import_dot.default,
54
- line: mode === "list" ? ListModeReporter : import_line.default,
55
- list: mode === "list" ? ListModeReporter : import_list.default,
53
+ dot: mode === "list" ? import_listModeReporter.default : import_dot.default,
54
+ line: mode === "list" ? import_listModeReporter.default : import_line.default,
55
+ list: mode === "list" ? import_listModeReporter.default : import_list.default,
56
56
  github: import_github.default,
57
57
  json: import_json.default,
58
58
  junit: import_junit.default,
@@ -81,7 +81,7 @@ async function createReporters(config, mode, isTestServer, descriptions) {
81
81
  const someReporterPrintsToStdio = reporters.some((r) => r.printsToStdio ? r.printsToStdio() : true);
82
82
  if (reporters.length && !someReporterPrintsToStdio) {
83
83
  if (mode === "list")
84
- reporters.unshift(new ListModeReporter());
84
+ reporters.unshift(new import_listModeReporter.default());
85
85
  else if (mode !== "merge")
86
86
  reporters.unshift(!process.env.CI ? new import_line.default() : new import_dot.default());
87
87
  }
@@ -93,14 +93,13 @@ async function createReporterForTestServer(file, messageSink) {
93
93
  _send: messageSink
94
94
  }));
95
95
  }
96
- function createErrorCollectingReporter(screen, writeToConsole) {
96
+ function createErrorCollectingReporter(screen) {
97
97
  const errors = [];
98
98
  return {
99
99
  version: () => "v2",
100
100
  onError(error) {
101
101
  errors.push(error);
102
- if (writeToConsole)
103
- process.stdout.write((0, import_base.formatError)(screen, error).message + "\n");
102
+ screen.stderr?.write((0, import_base.formatError)(screen, error).message + "\n");
104
103
  },
105
104
  errors: () => errors
106
105
  };
@@ -130,30 +129,6 @@ function computeCommandHash(config) {
130
129
  parts.push((0, import_utils.calculateSha1)(JSON.stringify(command)).substring(0, 7));
131
130
  return parts.join("-");
132
131
  }
133
- class ListModeReporter {
134
- version() {
135
- return "v2";
136
- }
137
- onConfigure(config) {
138
- this.config = config;
139
- }
140
- onBegin(suite) {
141
- console.log(`Listing tests:`);
142
- const tests = suite.allTests();
143
- const files = /* @__PURE__ */ new Set();
144
- for (const test of tests) {
145
- const [, projectName, , ...titles] = test.titlePath();
146
- const location = `${import_path.default.relative(this.config.rootDir, test.location.file)}:${test.location.line}:${test.location.column}`;
147
- const projectTitle = projectName ? `[${projectName}] \u203A ` : "";
148
- console.log(` ${projectTitle}${location} \u203A ${titles.join(" \u203A ")}`);
149
- files.add(test.location.file);
150
- }
151
- console.log(`Total: ${tests.length} ${tests.length === 1 ? "test" : "tests"} in ${files.size} ${files.size === 1 ? "file" : "files"}`);
152
- }
153
- onError(error) {
154
- console.error("\n" + (0, import_base.formatError)(import_base.terminalScreen, error).message);
155
- }
156
- }
157
132
  // Annotate the CommonJS export names for ESM import in node:
158
133
  0 && (module.exports = {
159
134
  createErrorCollectingReporter,
@@ -247,15 +247,6 @@ function createLoadTask(mode, options) {
247
247
  const changedFiles = await (0, import_vcs.detectChangedTestFiles)(testRun.config.cliOnlyChanged, testRun.config.configDir);
248
248
  testRun.config.preOnlyTestFilters.push((test) => changedFiles.has(test.location.file));
249
249
  }
250
- if (testRun.config.cliFilterFile) {
251
- try {
252
- testRun.config.preOnlyTestFilters.push(await (0, import_util2.loadTestFilterFile)(testRun.config.cliFilterFile));
253
- } catch (error) {
254
- if (options.failOnLoadErrors)
255
- throw error;
256
- softErrors.push(error);
257
- }
258
- }
259
250
  testRun.rootSuite = await (0, import_loadUtils.createRootSuite)(testRun, options.failOnLoadErrors ? errors : softErrors, !!options.filterOnly);
260
251
  testRun.failureTracker.onRootSuite(testRun.rootSuite);
261
252
  if (options.failOnLoadErrors && !testRun.rootSuite.allTests().length && !testRun.config.cliPassWithNoTests && !testRun.config.config.shard && !testRun.config.cliOnlyChanged) {
@@ -0,0 +1,402 @@
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
+ RecoverFromStepError: "recoverFromStepError"
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._recoverFromStepErrors = false;
67
+ this._resumeAfterStepErrors = /* @__PURE__ */ new Map();
68
+ this._configLocation = configLocation;
69
+ this._configCLIOverrides = configCLIOverrides;
70
+ this._watcher = new import_fsWatcher.Watcher((events) => {
71
+ const collector = /* @__PURE__ */ new Set();
72
+ events.forEach((f) => (0, import_compilationCache.collectAffectedTestFiles)(f.file, collector));
73
+ this.emit(TestRunnerEvent.TestFilesChanged, [...collector]);
74
+ });
75
+ }
76
+ async initialize(params) {
77
+ this._watchTestDirs = !!params.watchTestDirs;
78
+ this._populateDependenciesOnList = !!params.populateDependenciesOnList;
79
+ this._recoverFromStepErrors = !!params.recoverFromStepErrors;
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, false);
100
+ }
101
+ async runGlobalSetup(userReporters) {
102
+ await this.runGlobalTeardown();
103
+ const reporter = new import_internalReporter.InternalReporter(userReporters);
104
+ const config = await this._loadConfigOrReportError(reporter, this._configCLIOverrides);
105
+ if (!config)
106
+ return { status: "failed" };
107
+ const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
108
+ ...(0, import_tasks.createGlobalSetupTasks)(config)
109
+ ]);
110
+ if (status !== "passed")
111
+ await cleanup();
112
+ else
113
+ this._globalSetup = { cleanup };
114
+ return { status };
115
+ }
116
+ async runGlobalTeardown() {
117
+ const globalSetup = this._globalSetup;
118
+ const status = await globalSetup?.cleanup();
119
+ this._globalSetup = void 0;
120
+ return { status };
121
+ }
122
+ async startDevServer(userReporter, mode) {
123
+ await this.stopDevServer();
124
+ const reporter = new import_internalReporter.InternalReporter([userReporter]);
125
+ const config = await this._loadConfigOrReportError(reporter);
126
+ if (!config)
127
+ return { status: "failed" };
128
+ const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
129
+ ...(0, import_tasks.createPluginSetupTasks)(config),
130
+ (0, import_tasks.createLoadTask)(mode, { failOnLoadErrors: true, filterOnly: false }),
131
+ (0, import_tasks.createStartDevServerTask)()
132
+ ]);
133
+ if (status !== "passed")
134
+ await cleanup();
135
+ else
136
+ this._devServer = { cleanup };
137
+ return { status };
138
+ }
139
+ async stopDevServer() {
140
+ const devServer = this._devServer;
141
+ const status = await devServer?.cleanup();
142
+ this._devServer = void 0;
143
+ return { status };
144
+ }
145
+ async clearCache(userReporter) {
146
+ const reporter = new import_internalReporter.InternalReporter(userReporter ? [userReporter] : []);
147
+ const config = await this._loadConfigOrReportError(reporter);
148
+ if (!config)
149
+ return { status: "failed" };
150
+ const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
151
+ ...(0, import_tasks.createPluginSetupTasks)(config),
152
+ (0, import_tasks.createClearCacheTask)(config)
153
+ ]);
154
+ return { status };
155
+ }
156
+ async listFiles(userReporter, projects) {
157
+ const reporter = new import_internalReporter.InternalReporter([userReporter]);
158
+ const config = await this._loadConfigOrReportError(reporter);
159
+ if (!config)
160
+ return { status: "failed" };
161
+ config.cliProjectFilter = projects?.length ? projects : void 0;
162
+ const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
163
+ (0, import_tasks.createListFilesTask)(),
164
+ (0, import_tasks.createReportBeginTask)()
165
+ ]);
166
+ return { status };
167
+ }
168
+ async listTests(userReporter, params) {
169
+ let result;
170
+ this._queue = this._queue.then(async () => {
171
+ const { config, status } = await this._innerListTests(userReporter, params);
172
+ if (config)
173
+ await this._updateWatchedDirs(config);
174
+ result = { status };
175
+ }).catch(printInternalError);
176
+ await this._queue;
177
+ return result;
178
+ }
179
+ async _innerListTests(userReporter, params) {
180
+ const overrides = {
181
+ ...this._configCLIOverrides,
182
+ repeatEach: 1,
183
+ retries: 0
184
+ };
185
+ const reporter = new import_internalReporter.InternalReporter([userReporter]);
186
+ const config = await this._loadConfigOrReportError(reporter, overrides);
187
+ if (!config)
188
+ return { status: "failed" };
189
+ config.cliArgs = params.locations || [];
190
+ config.cliGrep = params.grep;
191
+ config.cliGrepInvert = params.grepInvert;
192
+ config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
193
+ config.cliListOnly = true;
194
+ const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
195
+ (0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
196
+ (0, import_tasks.createReportBeginTask)()
197
+ ]);
198
+ return { config, status };
199
+ }
200
+ async _updateWatchedDirs(config) {
201
+ this._watchedProjectDirs = /* @__PURE__ */ new Set();
202
+ this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
203
+ for (const p of config.projects) {
204
+ this._watchedProjectDirs.add(p.project.testDir);
205
+ this._ignoredProjectOutputs.add(p.project.outputDir);
206
+ }
207
+ const result = await resolveCtDirs(config);
208
+ if (result) {
209
+ this._watchedProjectDirs.add(result.templateDir);
210
+ this._ignoredProjectOutputs.add(result.outDir);
211
+ }
212
+ if (this._watchTestDirs)
213
+ await this._updateWatcher(false);
214
+ }
215
+ async _updateWatcher(reportPending) {
216
+ await this._watcher.update([...this._watchedProjectDirs, ...this._watchedTestDependencies], [...this._ignoredProjectOutputs], reportPending);
217
+ }
218
+ async runTests(userReporter, params) {
219
+ let result = { status: "passed" };
220
+ this._queue = this._queue.then(async () => {
221
+ result = await this._innerRunTests(userReporter, params).catch((e) => {
222
+ printInternalError(e);
223
+ return { status: "failed" };
224
+ });
225
+ });
226
+ await this._queue;
227
+ return result;
228
+ }
229
+ async _innerRunTests(userReporter, params) {
230
+ await this.stopTests();
231
+ const overrides = {
232
+ ...this._configCLIOverrides,
233
+ repeatEach: 1,
234
+ retries: 0,
235
+ preserveOutputDir: true,
236
+ reporter: params.reporters ? params.reporters.map((r) => [r]) : void 0,
237
+ use: {
238
+ ...this._configCLIOverrides.use,
239
+ ...params.trace === "on" ? { trace: { mode: "on", sources: false, _live: true } } : {},
240
+ ...params.trace === "off" ? { trace: "off" } : {},
241
+ ...params.video === "on" || params.video === "off" ? { video: params.video } : {},
242
+ ...params.headed !== void 0 ? { headless: !params.headed } : {},
243
+ _optionContextReuseMode: params.reuseContext ? "when-possible" : void 0,
244
+ _optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : void 0
245
+ },
246
+ ...params.updateSnapshots ? { updateSnapshots: params.updateSnapshots } : {},
247
+ ...params.updateSourceMethod ? { updateSourceMethod: params.updateSourceMethod } : {},
248
+ ...params.workers ? { workers: params.workers } : {}
249
+ };
250
+ if (params.trace === "on")
251
+ process.env.PW_LIVE_TRACE_STACKS = "1";
252
+ else
253
+ process.env.PW_LIVE_TRACE_STACKS = void 0;
254
+ const config = await this._loadConfigOrReportError(new import_internalReporter.InternalReporter([userReporter]), overrides);
255
+ if (!config)
256
+ return { status: "failed" };
257
+ config.cliListOnly = false;
258
+ config.cliPassWithNoTests = true;
259
+ config.cliArgs = params.locations || [];
260
+ config.cliGrep = params.grep;
261
+ config.cliGrepInvert = params.grepInvert;
262
+ config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
263
+ config.preOnlyTestFilters = [];
264
+ if (params.testIds) {
265
+ const testIdSet = new Set(params.testIds);
266
+ config.preOnlyTestFilters.push((test) => testIdSet.has(test.id));
267
+ }
268
+ const configReporters = await (0, import_reporters.createReporters)(config, "test", true);
269
+ const reporter = new import_internalReporter.InternalReporter([...configReporters, userReporter]);
270
+ const stop = new import_utils.ManualPromise();
271
+ const tasks = [
272
+ (0, import_tasks.createApplyRebaselinesTask)(),
273
+ (0, import_tasks.createLoadTask)("out-of-process", { filterOnly: true, failOnLoadErrors: false, doNotRunDepsOutsideProjectFilter: true }),
274
+ ...(0, import_tasks.createRunTestsTasks)(config)
275
+ ];
276
+ const testRun = new import_tasks.TestRun(config, reporter);
277
+ testRun.failureTracker.setRecoverFromStepErrorHandler(this._recoverFromStepError.bind(this));
278
+ const run = (0, import_tasks.runTasks)(testRun, tasks, 0, stop).then(async (status) => {
279
+ this._testRun = void 0;
280
+ return status;
281
+ });
282
+ this._testRun = { run, stop };
283
+ return { status: await run };
284
+ }
285
+ async _recoverFromStepError(stepId, error) {
286
+ if (!this._recoverFromStepErrors)
287
+ return { stepId, status: "failed" };
288
+ const recoveryPromise = new import_utils.ManualPromise();
289
+ this._resumeAfterStepErrors.set(stepId, recoveryPromise);
290
+ if (!error?.message || !error?.location)
291
+ return { stepId, status: "failed" };
292
+ this.emit(TestRunnerEvent.RecoverFromStepError, stepId, error.message, error.location);
293
+ const recoveredResult = await recoveryPromise;
294
+ if (recoveredResult.stepId !== stepId)
295
+ return { stepId, status: "failed" };
296
+ return recoveredResult;
297
+ }
298
+ async resumeAfterStepError(params) {
299
+ const recoveryPromise = this._resumeAfterStepErrors.get(params.stepId);
300
+ if (recoveryPromise)
301
+ recoveryPromise.resolve(params);
302
+ }
303
+ async watch(fileNames) {
304
+ this._watchedTestDependencies = /* @__PURE__ */ new Set();
305
+ for (const fileName of fileNames) {
306
+ this._watchedTestDependencies.add(fileName);
307
+ (0, import_compilationCache.dependenciesForTestFile)(fileName).forEach((file) => this._watchedTestDependencies.add(file));
308
+ }
309
+ await this._updateWatcher(true);
310
+ }
311
+ async findRelatedTestFiles(files, userReporter) {
312
+ const errorReporter = (0, import_reporters.createErrorCollectingReporter)(import_base.internalScreen);
313
+ const reporter = new import_internalReporter.InternalReporter(userReporter ? [userReporter, errorReporter] : [errorReporter]);
314
+ const config = await this._loadConfigOrReportError(reporter);
315
+ if (!config)
316
+ return { errors: errorReporter.errors(), testFiles: [] };
317
+ const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
318
+ ...(0, import_tasks.createPluginSetupTasks)(config),
319
+ (0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false, populateDependencies: true })
320
+ ]);
321
+ if (status !== "passed")
322
+ return { errors: errorReporter.errors(), testFiles: [] };
323
+ return { testFiles: (0, import_compilationCache.affectedTestFiles)(files) };
324
+ }
325
+ async stopTests() {
326
+ this._testRun?.stop?.resolve();
327
+ await this._testRun?.run;
328
+ this._resumeAfterStepErrors.clear();
329
+ }
330
+ async closeGracefully() {
331
+ (0, import_utils.gracefullyProcessExitDoNotHang)(0);
332
+ }
333
+ async _loadConfig(overrides) {
334
+ try {
335
+ const config = await (0, import_configLoader.loadConfig)(this._configLocation, overrides);
336
+ if (!this._plugins) {
337
+ (0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
338
+ (0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
339
+ this._plugins = config.plugins || [];
340
+ } else {
341
+ config.plugins.splice(0, config.plugins.length, ...this._plugins);
342
+ }
343
+ return { config };
344
+ } catch (e) {
345
+ return { config: null, error: (0, import_util.serializeError)(e) };
346
+ }
347
+ }
348
+ async _loadConfigOrReportError(reporter, overrides) {
349
+ const { config, error } = await this._loadConfig(overrides);
350
+ if (config)
351
+ return config;
352
+ reporter.onConfigure(import_teleReceiver.baseFullConfig);
353
+ reporter.onError(error);
354
+ await reporter.onEnd({ status: "failed" });
355
+ await reporter.onExit();
356
+ return null;
357
+ }
358
+ }
359
+ function printInternalError(e) {
360
+ console.error("Internal error:", e);
361
+ }
362
+ async function resolveCtDirs(config) {
363
+ const use = config.config.projects[0].use;
364
+ const relativeTemplateDir = use.ctTemplateDir || "playwright";
365
+ const templateDir = await import_fs.default.promises.realpath(import_path.default.normalize(import_path.default.join(config.configDir, relativeTemplateDir))).catch(() => void 0);
366
+ if (!templateDir)
367
+ return null;
368
+ const outDir = use.ctCacheDir ? import_path.default.resolve(config.configDir, use.ctCacheDir) : import_path.default.resolve(templateDir, ".cache");
369
+ return {
370
+ outDir,
371
+ templateDir
372
+ };
373
+ }
374
+ async function runAllTestsWithConfig(config) {
375
+ const listOnly = config.cliListOnly;
376
+ (0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
377
+ (0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
378
+ const reporters = await (0, import_reporters.createReporters)(config, listOnly ? "list" : "test", false);
379
+ const lastRun = new import_lastRun.LastRunReporter(config);
380
+ if (config.cliLastFailed)
381
+ await lastRun.filterLastFailed();
382
+ const reporter = new import_internalReporter.InternalReporter([...reporters, lastRun]);
383
+ const tasks = listOnly ? [
384
+ (0, import_tasks.createLoadTask)("in-process", { failOnLoadErrors: true, filterOnly: false }),
385
+ (0, import_tasks.createReportBeginTask)()
386
+ ] : [
387
+ (0, import_tasks.createApplyRebaselinesTask)(),
388
+ ...(0, import_tasks.createGlobalSetupTasks)(config),
389
+ (0, import_tasks.createLoadTask)("in-process", { filterOnly: true, failOnLoadErrors: true }),
390
+ ...(0, import_tasks.createRunTestsTasks)(config)
391
+ ];
392
+ const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), tasks, config.config.globalTimeout);
393
+ await new Promise((resolve) => process.stdout.write("", () => resolve()));
394
+ await new Promise((resolve) => process.stderr.write("", () => resolve()));
395
+ return status;
396
+ }
397
+ // Annotate the CommonJS export names for ESM import in node:
398
+ 0 && (module.exports = {
399
+ TestRunner,
400
+ TestRunnerEvent,
401
+ runAllTestsWithConfig
402
+ });