playwright 1.55.0-alpha-2025-08-12 → 1.55.0-alpha-2025-08-14
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.
- package/lib/index.js +6 -2
- package/lib/isomorphic/testServerConnection.js +7 -0
- package/lib/matchers/expect.js +23 -11
- package/lib/reporters/html.js +1 -1
- package/lib/reporters/markdown.js +3 -3
- package/lib/runner/dispatcher.js +22 -1
- package/lib/runner/failureTracker.js +14 -0
- package/lib/runner/testRunner.js +372 -0
- package/lib/runner/testServer.js +53 -271
- package/lib/runner/watchMode.js +57 -1
- package/lib/runner/workerHost.js +6 -2
- package/lib/util.js +0 -19
- package/lib/worker/fixtureRunner.js +1 -1
- package/lib/worker/testInfo.js +26 -3
- package/lib/worker/testTracing.js +1 -1
- package/lib/worker/workerMain.js +5 -0
- package/package.json +2 -2
- package/types/test.d.ts +15 -15
package/lib/index.js
CHANGED
|
@@ -42,7 +42,6 @@ var playwrightLibrary = __toESM(require("playwright-core"));
|
|
|
42
42
|
var import_utils = require("playwright-core/lib/utils");
|
|
43
43
|
var import_globals = require("./common/globals");
|
|
44
44
|
var import_testType = require("./common/testType");
|
|
45
|
-
var import_util = require("./util");
|
|
46
45
|
var import_expect = require("./matchers/expect");
|
|
47
46
|
var import_configLoader = require("./common/configLoader");
|
|
48
47
|
var import_testType2 = require("./common/testType");
|
|
@@ -242,7 +241,7 @@ const playwrightFixtures = {
|
|
|
242
241
|
if (zone.apiName)
|
|
243
242
|
data.apiName = zone.apiName;
|
|
244
243
|
if (zone.title)
|
|
245
|
-
data.title =
|
|
244
|
+
data.title = zone.title;
|
|
246
245
|
data.stepId = zone.stepId;
|
|
247
246
|
return;
|
|
248
247
|
}
|
|
@@ -259,6 +258,11 @@ const playwrightFixtures = {
|
|
|
259
258
|
if (data.apiName === "tracing.group")
|
|
260
259
|
tracingGroupSteps.push(step);
|
|
261
260
|
},
|
|
261
|
+
onApiCallRecovery: (data, error, recoveryHandlers) => {
|
|
262
|
+
const step = data.userData;
|
|
263
|
+
if (step)
|
|
264
|
+
recoveryHandlers.push(() => step.recoverFromStepError(error));
|
|
265
|
+
},
|
|
262
266
|
onApiCallEnd: (data) => {
|
|
263
267
|
if (data.apiName === "tracing.group")
|
|
264
268
|
return;
|
|
@@ -63,6 +63,7 @@ class TestServerConnection {
|
|
|
63
63
|
this._onStdioEmitter = new events.EventEmitter();
|
|
64
64
|
this._onTestFilesChangedEmitter = new events.EventEmitter();
|
|
65
65
|
this._onLoadTraceRequestedEmitter = new events.EventEmitter();
|
|
66
|
+
this._onRecoverFromStepErrorEmitter = new events.EventEmitter();
|
|
66
67
|
this._lastId = 0;
|
|
67
68
|
this._callbacks = /* @__PURE__ */ new Map();
|
|
68
69
|
this._isClosed = false;
|
|
@@ -71,6 +72,7 @@ class TestServerConnection {
|
|
|
71
72
|
this.onStdio = this._onStdioEmitter.event;
|
|
72
73
|
this.onTestFilesChanged = this._onTestFilesChangedEmitter.event;
|
|
73
74
|
this.onLoadTraceRequested = this._onLoadTraceRequestedEmitter.event;
|
|
75
|
+
this.onRecoverFromStepError = this._onRecoverFromStepErrorEmitter.event;
|
|
74
76
|
this._transport = transport;
|
|
75
77
|
this._transport.onmessage((data) => {
|
|
76
78
|
const message = JSON.parse(data);
|
|
@@ -127,6 +129,8 @@ class TestServerConnection {
|
|
|
127
129
|
this._onTestFilesChangedEmitter.fire(params);
|
|
128
130
|
else if (method === "loadTraceRequested")
|
|
129
131
|
this._onLoadTraceRequestedEmitter.fire(params);
|
|
132
|
+
else if (method === "recoverFromStepError")
|
|
133
|
+
this._onRecoverFromStepErrorEmitter.fire(params);
|
|
130
134
|
}
|
|
131
135
|
async initialize(params) {
|
|
132
136
|
await this._sendMessage("initialize", params);
|
|
@@ -197,6 +201,9 @@ class TestServerConnection {
|
|
|
197
201
|
async closeGracefully(params) {
|
|
198
202
|
await this._sendMessage("closeGracefully", params);
|
|
199
203
|
}
|
|
204
|
+
async resumeAfterStepError(params) {
|
|
205
|
+
await this._sendMessage("resumeAfterStepError", params);
|
|
206
|
+
}
|
|
200
207
|
close() {
|
|
201
208
|
try {
|
|
202
209
|
this._transport.close();
|
package/lib/matchers/expect.js
CHANGED
|
@@ -222,31 +222,43 @@ class ExpectMetaInfoProxyHandler {
|
|
|
222
222
|
const customMessage = this._info.message || "";
|
|
223
223
|
const argsSuffix = computeArgsSuffix(matcherName, args);
|
|
224
224
|
const defaultTitle = `${this._info.poll ? "poll " : ""}${this._info.isSoft ? "soft " : ""}${this._info.isNot ? "not " : ""}${matcherName}${argsSuffix}`;
|
|
225
|
-
const title = customMessage || defaultTitle
|
|
225
|
+
const title = customMessage || `Expect ${(0, import_utils.escapeWithQuotes)(defaultTitle, '"')}`;
|
|
226
226
|
const apiName = `expect${this._info.poll ? ".poll " : ""}${this._info.isSoft ? ".soft " : ""}${this._info.isNot ? ".not" : ""}.${matcherName}${argsSuffix}`;
|
|
227
227
|
const stackFrames = (0, import_util.filteredStackTrace)((0, import_utils.captureRawStack)());
|
|
228
228
|
const category = matcherName === "toPass" || this._info.poll ? "test.step" : "expect";
|
|
229
|
-
const formattedTitle = category === "expect" ? title : `Expect "${title}"`;
|
|
230
229
|
const stepInfo = {
|
|
231
230
|
category,
|
|
232
231
|
apiName,
|
|
233
|
-
title
|
|
232
|
+
title,
|
|
234
233
|
params: args[0] ? { expected: args[0] } : void 0,
|
|
235
234
|
infectParentStepsWithError: this._info.isSoft
|
|
236
235
|
};
|
|
237
236
|
const step = testInfo._addStep(stepInfo);
|
|
238
|
-
const reportStepError = (e) => {
|
|
237
|
+
const reportStepError = (isAsync, e) => {
|
|
239
238
|
const jestError = (0, import_matcherHint.isJestError)(e) ? e : null;
|
|
240
|
-
const
|
|
239
|
+
const expectError = jestError ? new import_matcherHint.ExpectError(jestError, customMessage, stackFrames) : void 0;
|
|
241
240
|
if (jestError?.matcherResult.suggestedRebaseline) {
|
|
242
241
|
step.complete({ suggestedRebaseline: jestError?.matcherResult.suggestedRebaseline });
|
|
243
242
|
return;
|
|
244
243
|
}
|
|
244
|
+
const error = expectError ?? e;
|
|
245
245
|
step.complete({ error });
|
|
246
|
-
if (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
if (!isAsync || !expectError) {
|
|
247
|
+
if (this._info.isSoft)
|
|
248
|
+
testInfo._failWithError(error);
|
|
249
|
+
else
|
|
250
|
+
throw error;
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
return (async () => {
|
|
254
|
+
const recoveryResult = await step.recoverFromStepError(expectError);
|
|
255
|
+
if (recoveryResult.status === "recovered")
|
|
256
|
+
return recoveryResult.value;
|
|
257
|
+
if (this._info.isSoft)
|
|
258
|
+
testInfo._failWithError(expectError);
|
|
259
|
+
else
|
|
260
|
+
throw expectError;
|
|
261
|
+
})();
|
|
250
262
|
};
|
|
251
263
|
const finalizer = () => {
|
|
252
264
|
step.complete({});
|
|
@@ -256,11 +268,11 @@ class ExpectMetaInfoProxyHandler {
|
|
|
256
268
|
const callback = () => matcher.call(target, ...args);
|
|
257
269
|
const result = (0, import_utils.currentZone)().with("stepZone", step).run(callback);
|
|
258
270
|
if (result instanceof Promise)
|
|
259
|
-
return result.then(finalizer).catch(reportStepError);
|
|
271
|
+
return result.then(finalizer).catch(reportStepError.bind(null, true));
|
|
260
272
|
finalizer();
|
|
261
273
|
return result;
|
|
262
274
|
} catch (e) {
|
|
263
|
-
reportStepError(e);
|
|
275
|
+
void reportStepError(false, e);
|
|
264
276
|
}
|
|
265
277
|
};
|
|
266
278
|
}
|
package/lib/reporters/html.js
CHANGED
|
@@ -472,7 +472,7 @@ class HtmlBuilder {
|
|
|
472
472
|
_createTestStep(dedupedStep, result) {
|
|
473
473
|
const { step, duration, count } = dedupedStep;
|
|
474
474
|
const skipped = dedupedStep.step.annotations?.find((a) => a.type === "skip");
|
|
475
|
-
let title =
|
|
475
|
+
let title = step.title;
|
|
476
476
|
if (skipped)
|
|
477
477
|
title = `${title} (skipped${skipped.description ? ": " + skipped.description : ""})`;
|
|
478
478
|
const testStep = {
|
|
@@ -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}
|
|
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
|
-
|
|
141
|
+
const formattedTags = extraTags.map((t) => `\`${t}\``).join(" ");
|
|
142
|
+
return `${testTitle}${extraTags.length ? " " + formattedTags : ""}`;
|
|
143
143
|
}
|
|
144
144
|
var markdown_default = MarkdownReporter;
|
package/lib/runner/dispatcher.js
CHANGED
|
@@ -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
|
|
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
|
}
|
|
@@ -0,0 +1,372 @@
|
|
|
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
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(testRunner_exports);
|
|
35
|
+
var import_events = __toESM(require("events"));
|
|
36
|
+
var import_fs = __toESM(require("fs"));
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_server = require("playwright-core/lib/server");
|
|
39
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
40
|
+
var import_configLoader = require("../common/configLoader");
|
|
41
|
+
var import_fsWatcher = require("../fsWatcher");
|
|
42
|
+
var import_teleReceiver = require("../isomorphic/teleReceiver");
|
|
43
|
+
var import_gitCommitInfoPlugin = require("../plugins/gitCommitInfoPlugin");
|
|
44
|
+
var import_webServerPlugin = require("../plugins/webServerPlugin");
|
|
45
|
+
var import_base = require("../reporters/base");
|
|
46
|
+
var import_internalReporter = require("../reporters/internalReporter");
|
|
47
|
+
var import_compilationCache = require("../transform/compilationCache");
|
|
48
|
+
var import_util = require("../util");
|
|
49
|
+
var import_reporters = require("./reporters");
|
|
50
|
+
var import_tasks = require("./tasks");
|
|
51
|
+
const TestRunnerEvent = {
|
|
52
|
+
TestFilesChanged: "testFilesChanged",
|
|
53
|
+
RecoverFromStepError: "recoverFromStepError"
|
|
54
|
+
};
|
|
55
|
+
class TestRunner extends import_events.default {
|
|
56
|
+
constructor(configLocation, configCLIOverrides) {
|
|
57
|
+
super();
|
|
58
|
+
this._watchedProjectDirs = /* @__PURE__ */ new Set();
|
|
59
|
+
this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
|
|
60
|
+
this._watchedTestDependencies = /* @__PURE__ */ new Set();
|
|
61
|
+
this._queue = Promise.resolve();
|
|
62
|
+
this._watchTestDirs = false;
|
|
63
|
+
this._populateDependenciesOnList = false;
|
|
64
|
+
this._recoverFromStepErrors = false;
|
|
65
|
+
this._resumeAfterStepErrors = /* @__PURE__ */ new Map();
|
|
66
|
+
this._configLocation = configLocation;
|
|
67
|
+
this._configCLIOverrides = configCLIOverrides;
|
|
68
|
+
this._watcher = new import_fsWatcher.Watcher((events) => {
|
|
69
|
+
const collector = /* @__PURE__ */ new Set();
|
|
70
|
+
events.forEach((f) => (0, import_compilationCache.collectAffectedTestFiles)(f.file, collector));
|
|
71
|
+
this.emit(TestRunnerEvent.TestFilesChanged, [...collector]);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async initialize(params) {
|
|
75
|
+
this._watchTestDirs = !!params.watchTestDirs;
|
|
76
|
+
this._populateDependenciesOnList = !!params.populateDependenciesOnList;
|
|
77
|
+
this._recoverFromStepErrors = !!params.recoverFromStepErrors;
|
|
78
|
+
}
|
|
79
|
+
resizeTerminal(params) {
|
|
80
|
+
process.stdout.columns = params.cols;
|
|
81
|
+
process.stdout.rows = params.rows;
|
|
82
|
+
process.stderr.columns = params.cols;
|
|
83
|
+
process.stderr.rows = params.rows;
|
|
84
|
+
}
|
|
85
|
+
hasSomeBrowsers() {
|
|
86
|
+
for (const browserName of ["chromium", "webkit", "firefox"]) {
|
|
87
|
+
try {
|
|
88
|
+
import_server.registry.findExecutable(browserName).executablePathOrDie("javascript");
|
|
89
|
+
return true;
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
async installBrowsers() {
|
|
96
|
+
const executables = import_server.registry.defaultExecutables();
|
|
97
|
+
await import_server.registry.install(executables, false);
|
|
98
|
+
}
|
|
99
|
+
async runGlobalSetup(userReporters) {
|
|
100
|
+
await this.runGlobalTeardown();
|
|
101
|
+
const reporter = new import_internalReporter.InternalReporter(userReporters);
|
|
102
|
+
const config = await this._loadConfigOrReportError(reporter, this._configCLIOverrides);
|
|
103
|
+
if (!config)
|
|
104
|
+
return { status: "failed" };
|
|
105
|
+
const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
|
|
106
|
+
...(0, import_tasks.createGlobalSetupTasks)(config)
|
|
107
|
+
]);
|
|
108
|
+
if (status !== "passed")
|
|
109
|
+
await cleanup();
|
|
110
|
+
else
|
|
111
|
+
this._globalSetup = { cleanup };
|
|
112
|
+
return { status };
|
|
113
|
+
}
|
|
114
|
+
async runGlobalTeardown() {
|
|
115
|
+
const globalSetup = this._globalSetup;
|
|
116
|
+
const status = await globalSetup?.cleanup();
|
|
117
|
+
this._globalSetup = void 0;
|
|
118
|
+
return { status };
|
|
119
|
+
}
|
|
120
|
+
async startDevServer(userReporters) {
|
|
121
|
+
await this.stopDevServer();
|
|
122
|
+
const reporter = new import_internalReporter.InternalReporter(userReporters);
|
|
123
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
124
|
+
if (!config)
|
|
125
|
+
return { status: "failed" };
|
|
126
|
+
const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
|
|
127
|
+
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false }),
|
|
128
|
+
(0, import_tasks.createStartDevServerTask)()
|
|
129
|
+
]);
|
|
130
|
+
if (status !== "passed")
|
|
131
|
+
await cleanup();
|
|
132
|
+
else
|
|
133
|
+
this._devServer = { cleanup };
|
|
134
|
+
return { status };
|
|
135
|
+
}
|
|
136
|
+
async stopDevServer() {
|
|
137
|
+
const devServer = this._devServer;
|
|
138
|
+
const status = await devServer?.cleanup();
|
|
139
|
+
this._devServer = void 0;
|
|
140
|
+
return { status };
|
|
141
|
+
}
|
|
142
|
+
async clearCache() {
|
|
143
|
+
const reporter = new import_internalReporter.InternalReporter([]);
|
|
144
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
145
|
+
if (!config)
|
|
146
|
+
return;
|
|
147
|
+
await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
148
|
+
(0, import_tasks.createClearCacheTask)(config)
|
|
149
|
+
]);
|
|
150
|
+
}
|
|
151
|
+
async listFiles(userReporters, params) {
|
|
152
|
+
const reporter = new import_internalReporter.InternalReporter(userReporters);
|
|
153
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
154
|
+
if (!config)
|
|
155
|
+
return { status: "failed" };
|
|
156
|
+
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
|
|
157
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
158
|
+
(0, import_tasks.createListFilesTask)(),
|
|
159
|
+
(0, import_tasks.createReportBeginTask)()
|
|
160
|
+
]);
|
|
161
|
+
return { status };
|
|
162
|
+
}
|
|
163
|
+
async listTests(userReporters, params) {
|
|
164
|
+
let result;
|
|
165
|
+
this._queue = this._queue.then(async () => {
|
|
166
|
+
const { config, status } = await this._innerListTests(userReporters, params);
|
|
167
|
+
if (config)
|
|
168
|
+
await this._updateWatchedDirs(config);
|
|
169
|
+
result = { status };
|
|
170
|
+
}).catch(printInternalError);
|
|
171
|
+
await this._queue;
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
async _innerListTests(userReporters, params) {
|
|
175
|
+
const overrides = {
|
|
176
|
+
...this._configCLIOverrides,
|
|
177
|
+
repeatEach: 1,
|
|
178
|
+
retries: 0
|
|
179
|
+
};
|
|
180
|
+
const reporter = new import_internalReporter.InternalReporter(userReporters);
|
|
181
|
+
const config = await this._loadConfigOrReportError(reporter, overrides);
|
|
182
|
+
if (!config)
|
|
183
|
+
return { status: "failed" };
|
|
184
|
+
config.cliArgs = params.locations || [];
|
|
185
|
+
config.cliGrep = params.grep;
|
|
186
|
+
config.cliGrepInvert = params.grepInvert;
|
|
187
|
+
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
|
|
188
|
+
config.cliListOnly = true;
|
|
189
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
190
|
+
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
|
|
191
|
+
(0, import_tasks.createReportBeginTask)()
|
|
192
|
+
]);
|
|
193
|
+
return { config, status };
|
|
194
|
+
}
|
|
195
|
+
async _updateWatchedDirs(config) {
|
|
196
|
+
this._watchedProjectDirs = /* @__PURE__ */ new Set();
|
|
197
|
+
this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
|
|
198
|
+
for (const p of config.projects) {
|
|
199
|
+
this._watchedProjectDirs.add(p.project.testDir);
|
|
200
|
+
this._ignoredProjectOutputs.add(p.project.outputDir);
|
|
201
|
+
}
|
|
202
|
+
const result = await resolveCtDirs(config);
|
|
203
|
+
if (result) {
|
|
204
|
+
this._watchedProjectDirs.add(result.templateDir);
|
|
205
|
+
this._ignoredProjectOutputs.add(result.outDir);
|
|
206
|
+
}
|
|
207
|
+
if (this._watchTestDirs)
|
|
208
|
+
await this._updateWatcher(false);
|
|
209
|
+
}
|
|
210
|
+
async _updateWatcher(reportPending) {
|
|
211
|
+
await this._watcher.update([...this._watchedProjectDirs, ...this._watchedTestDependencies], [...this._ignoredProjectOutputs], reportPending);
|
|
212
|
+
}
|
|
213
|
+
async runTests(userReporters, params) {
|
|
214
|
+
let result = { status: "passed" };
|
|
215
|
+
this._queue = this._queue.then(async () => {
|
|
216
|
+
result = await this._innerRunTests(userReporters, params).catch((e) => {
|
|
217
|
+
printInternalError(e);
|
|
218
|
+
return { status: "failed" };
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
await this._queue;
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
async _innerRunTests(userReporters, params) {
|
|
225
|
+
await this.stopTests();
|
|
226
|
+
const overrides = {
|
|
227
|
+
...this._configCLIOverrides,
|
|
228
|
+
repeatEach: 1,
|
|
229
|
+
retries: 0,
|
|
230
|
+
preserveOutputDir: true,
|
|
231
|
+
reporter: params.reporters ? params.reporters.map((r) => [r]) : void 0,
|
|
232
|
+
use: {
|
|
233
|
+
...this._configCLIOverrides.use,
|
|
234
|
+
...params.trace === "on" ? { trace: { mode: "on", sources: false, _live: true } } : {},
|
|
235
|
+
...params.trace === "off" ? { trace: "off" } : {},
|
|
236
|
+
...params.video === "on" || params.video === "off" ? { video: params.video } : {},
|
|
237
|
+
...params.headed !== void 0 ? { headless: !params.headed } : {},
|
|
238
|
+
_optionContextReuseMode: params.reuseContext ? "when-possible" : void 0,
|
|
239
|
+
_optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : void 0
|
|
240
|
+
},
|
|
241
|
+
...params.updateSnapshots ? { updateSnapshots: params.updateSnapshots } : {},
|
|
242
|
+
...params.updateSourceMethod ? { updateSourceMethod: params.updateSourceMethod } : {},
|
|
243
|
+
...params.workers ? { workers: params.workers } : {}
|
|
244
|
+
};
|
|
245
|
+
if (params.trace === "on")
|
|
246
|
+
process.env.PW_LIVE_TRACE_STACKS = "1";
|
|
247
|
+
else
|
|
248
|
+
process.env.PW_LIVE_TRACE_STACKS = void 0;
|
|
249
|
+
const config = await this._loadConfigOrReportError(new import_internalReporter.InternalReporter(userReporters), overrides);
|
|
250
|
+
if (!config)
|
|
251
|
+
return { status: "failed" };
|
|
252
|
+
config.cliListOnly = false;
|
|
253
|
+
config.cliPassWithNoTests = true;
|
|
254
|
+
config.cliArgs = params.locations || [];
|
|
255
|
+
config.cliGrep = params.grep;
|
|
256
|
+
config.cliGrepInvert = params.grepInvert;
|
|
257
|
+
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
|
|
258
|
+
config.preOnlyTestFilters = [];
|
|
259
|
+
if (params.testIds) {
|
|
260
|
+
const testIdSet = new Set(params.testIds);
|
|
261
|
+
config.preOnlyTestFilters.push((test) => testIdSet.has(test.id));
|
|
262
|
+
}
|
|
263
|
+
const configReporters = await (0, import_reporters.createReporters)(config, "test", true);
|
|
264
|
+
const reporter = new import_internalReporter.InternalReporter([...configReporters, ...userReporters]);
|
|
265
|
+
const stop = new import_utils.ManualPromise();
|
|
266
|
+
const tasks = [
|
|
267
|
+
(0, import_tasks.createApplyRebaselinesTask)(),
|
|
268
|
+
(0, import_tasks.createLoadTask)("out-of-process", { filterOnly: true, failOnLoadErrors: false, doNotRunDepsOutsideProjectFilter: true }),
|
|
269
|
+
...(0, import_tasks.createRunTestsTasks)(config)
|
|
270
|
+
];
|
|
271
|
+
const testRun = new import_tasks.TestRun(config, reporter);
|
|
272
|
+
testRun.failureTracker.setRecoverFromStepErrorHandler(this._recoverFromStepError.bind(this));
|
|
273
|
+
const run = (0, import_tasks.runTasks)(testRun, tasks, 0, stop).then(async (status) => {
|
|
274
|
+
this._testRun = void 0;
|
|
275
|
+
return status;
|
|
276
|
+
});
|
|
277
|
+
this._testRun = { run, stop };
|
|
278
|
+
return { status: await run };
|
|
279
|
+
}
|
|
280
|
+
async _recoverFromStepError(stepId, error) {
|
|
281
|
+
if (!this._recoverFromStepErrors)
|
|
282
|
+
return { stepId, status: "failed" };
|
|
283
|
+
const recoveryPromise = new import_utils.ManualPromise();
|
|
284
|
+
this._resumeAfterStepErrors.set(stepId, recoveryPromise);
|
|
285
|
+
if (!error?.message || !error?.location)
|
|
286
|
+
return { stepId, status: "failed" };
|
|
287
|
+
this.emit(TestRunnerEvent.RecoverFromStepError, stepId, error.message, error.location);
|
|
288
|
+
const recoveredResult = await recoveryPromise;
|
|
289
|
+
if (recoveredResult.stepId !== stepId)
|
|
290
|
+
return { stepId, status: "failed" };
|
|
291
|
+
return recoveredResult;
|
|
292
|
+
}
|
|
293
|
+
async resumeAfterStepError(params) {
|
|
294
|
+
const recoveryPromise = this._resumeAfterStepErrors.get(params.stepId);
|
|
295
|
+
if (recoveryPromise)
|
|
296
|
+
recoveryPromise.resolve(params);
|
|
297
|
+
}
|
|
298
|
+
async watch(params) {
|
|
299
|
+
this._watchedTestDependencies = /* @__PURE__ */ new Set();
|
|
300
|
+
for (const fileName of params.fileNames) {
|
|
301
|
+
this._watchedTestDependencies.add(fileName);
|
|
302
|
+
(0, import_compilationCache.dependenciesForTestFile)(fileName).forEach((file) => this._watchedTestDependencies.add(file));
|
|
303
|
+
}
|
|
304
|
+
await this._updateWatcher(true);
|
|
305
|
+
}
|
|
306
|
+
async findRelatedTestFiles(params) {
|
|
307
|
+
const errorReporter = (0, import_reporters.createErrorCollectingReporter)(import_base.internalScreen);
|
|
308
|
+
const reporter = new import_internalReporter.InternalReporter([errorReporter]);
|
|
309
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
310
|
+
if (!config)
|
|
311
|
+
return { errors: errorReporter.errors(), testFiles: [] };
|
|
312
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
313
|
+
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false, populateDependencies: true })
|
|
314
|
+
]);
|
|
315
|
+
if (status !== "passed")
|
|
316
|
+
return { errors: errorReporter.errors(), testFiles: [] };
|
|
317
|
+
return { testFiles: (0, import_compilationCache.affectedTestFiles)(params.files) };
|
|
318
|
+
}
|
|
319
|
+
async stopTests() {
|
|
320
|
+
this._testRun?.stop?.resolve();
|
|
321
|
+
await this._testRun?.run;
|
|
322
|
+
this._resumeAfterStepErrors.clear();
|
|
323
|
+
}
|
|
324
|
+
async closeGracefully() {
|
|
325
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(0);
|
|
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
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
369
|
+
0 && (module.exports = {
|
|
370
|
+
TestRunner,
|
|
371
|
+
TestRunnerEvent
|
|
372
|
+
});
|