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.
- package/README.md +2 -2
- package/lib/index.js +5 -0
- package/lib/isomorphic/testServerConnection.js +7 -0
- package/lib/matchers/expect.js +21 -8
- package/lib/program.js +9 -59
- package/lib/reporters/base.js +18 -11
- package/lib/reporters/dot.js +11 -11
- package/lib/reporters/github.js +2 -1
- package/lib/reporters/html.js +14 -11
- package/lib/reporters/internalReporter.js +2 -1
- package/lib/reporters/line.js +15 -15
- package/lib/reporters/list.js +15 -15
- package/lib/reporters/listModeReporter.js +66 -0
- package/lib/reporters/markdown.js +3 -3
- package/lib/runner/dispatcher.js +22 -1
- package/lib/runner/failureTracker.js +14 -0
- package/lib/runner/reporters.js +7 -32
- package/lib/runner/tasks.js +0 -9
- package/lib/runner/testRunner.js +402 -0
- package/lib/runner/testServer.js +57 -273
- package/lib/runner/watchMode.js +57 -1
- package/lib/runner/workerHost.js +6 -2
- package/lib/transform/transform.js +1 -1
- package/lib/util.js +0 -18
- package/lib/worker/testInfo.js +24 -1
- package/lib/worker/workerMain.js +5 -0
- package/package.json +3 -2
- package/lib/runner/runner.js +0 -110
package/lib/runner/testServer.js
CHANGED
|
@@ -28,31 +28,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var testServer_exports = {};
|
|
30
30
|
__export(testServer_exports, {
|
|
31
|
+
TestRunnerEvent: () => TestRunnerEvent,
|
|
31
32
|
TestServerDispatcher: () => TestServerDispatcher,
|
|
32
|
-
resolveCtDirs: () => resolveCtDirs,
|
|
33
33
|
runTestServer: () => runTestServer,
|
|
34
34
|
runUIMode: () => runUIMode
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(testServer_exports);
|
|
37
|
-
var import_fs = __toESM(require("fs"));
|
|
38
|
-
var import_path = __toESM(require("path"));
|
|
39
37
|
var import_util = __toESM(require("util"));
|
|
40
38
|
var import_server = require("playwright-core/lib/server");
|
|
41
39
|
var import_utils = require("playwright-core/lib/utils");
|
|
42
40
|
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
43
|
-
var import_reporters = require("./reporters");
|
|
44
|
-
var import_sigIntWatcher = require("./sigIntWatcher");
|
|
45
|
-
var import_tasks = require("./tasks");
|
|
46
41
|
var import_configLoader = require("../common/configLoader");
|
|
47
|
-
var import_fsWatcher = require("../fsWatcher");
|
|
48
|
-
var import_teleReceiver = require("../isomorphic/teleReceiver");
|
|
49
|
-
var import_gitCommitInfoPlugin = require("../plugins/gitCommitInfoPlugin");
|
|
50
|
-
var import_webServerPlugin = require("../plugins/webServerPlugin");
|
|
51
|
-
var import_base = require("../reporters/base");
|
|
52
|
-
var import_internalReporter = require("../reporters/internalReporter");
|
|
53
42
|
var import_list = __toESM(require("../reporters/list"));
|
|
54
|
-
var
|
|
55
|
-
var
|
|
43
|
+
var import_reporters = require("./reporters");
|
|
44
|
+
var import_sigIntWatcher = require("./sigIntWatcher");
|
|
45
|
+
var import_testRunner = require("./testRunner");
|
|
56
46
|
const originalDebugLog = import_utilsBundle.debug.log;
|
|
57
47
|
const originalStdoutWrite = process.stdout.write;
|
|
58
48
|
const originalStderrWrite = process.stderr.write;
|
|
@@ -70,18 +60,15 @@ class TestServer {
|
|
|
70
60
|
await this._dispatcher?.runGlobalTeardown();
|
|
71
61
|
}
|
|
72
62
|
}
|
|
63
|
+
const TestRunnerEvent = {
|
|
64
|
+
TestFilesChanged: "testFilesChanged",
|
|
65
|
+
RecoverFromStepError: "recoverFromStepError"
|
|
66
|
+
};
|
|
73
67
|
class TestServerDispatcher {
|
|
74
68
|
constructor(configLocation, configCLIOverrides) {
|
|
75
|
-
this._watchedProjectDirs = /* @__PURE__ */ new Set();
|
|
76
|
-
this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
|
|
77
|
-
this._watchedTestDependencies = /* @__PURE__ */ new Set();
|
|
78
|
-
this._queue = Promise.resolve();
|
|
79
69
|
this._serializer = require.resolve("./uiModeReporter");
|
|
80
|
-
this._watchTestDirs = false;
|
|
81
70
|
this._closeOnDisconnect = false;
|
|
82
|
-
this.
|
|
83
|
-
this._configLocation = configLocation;
|
|
84
|
-
this._configCLIOverrides = configCLIOverrides;
|
|
71
|
+
this._testRunner = new import_testRunner.TestRunner(configLocation, configCLIOverrides);
|
|
85
72
|
this.transport = {
|
|
86
73
|
onconnect: () => {
|
|
87
74
|
},
|
|
@@ -91,27 +78,29 @@ class TestServerDispatcher {
|
|
|
91
78
|
(0, import_utils.gracefullyProcessExitDoNotHang)(0);
|
|
92
79
|
}
|
|
93
80
|
};
|
|
94
|
-
this._watcher = new import_fsWatcher.Watcher((events) => {
|
|
95
|
-
const collector = /* @__PURE__ */ new Set();
|
|
96
|
-
events.forEach((f) => (0, import_compilationCache.collectAffectedTestFiles)(f.file, collector));
|
|
97
|
-
this._dispatchEvent("testFilesChanged", { testFiles: [...collector] });
|
|
98
|
-
});
|
|
99
81
|
this._dispatchEvent = (method, params) => this.transport.sendEvent?.(method, params);
|
|
82
|
+
this._testRunner.on(TestRunnerEvent.TestFilesChanged, (testFiles) => this._dispatchEvent("testFilesChanged", { testFiles }));
|
|
83
|
+
this._testRunner.on(TestRunnerEvent.RecoverFromStepError, (stepId, message, location) => this._dispatchEvent("recoverFromStepError", { stepId, message, location }));
|
|
100
84
|
}
|
|
101
85
|
async _wireReporter(messageSink) {
|
|
102
86
|
return await (0, import_reporters.createReporterForTestServer)(this._serializer, messageSink);
|
|
103
87
|
}
|
|
104
|
-
async
|
|
88
|
+
async _collectingReporter() {
|
|
105
89
|
const report = [];
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
return {
|
|
91
|
+
reporter: await (0, import_reporters.createReporterForTestServer)(this._serializer, (e) => report.push(e)),
|
|
92
|
+
report
|
|
93
|
+
};
|
|
108
94
|
}
|
|
109
95
|
async initialize(params) {
|
|
110
96
|
this._serializer = params.serializer || require.resolve("./uiModeReporter");
|
|
111
97
|
this._closeOnDisconnect = !!params.closeOnDisconnect;
|
|
112
98
|
await this._setInterceptStdio(!!params.interceptStdio);
|
|
113
|
-
this.
|
|
114
|
-
|
|
99
|
+
await this._testRunner.initialize({
|
|
100
|
+
watchTestDirs: !!params.watchTestDirs,
|
|
101
|
+
populateDependenciesOnList: !!params.populateDependenciesOnList,
|
|
102
|
+
recoverFromStepErrors: !!params.recoverFromStepErrors
|
|
103
|
+
});
|
|
115
104
|
}
|
|
116
105
|
async ping() {
|
|
117
106
|
}
|
|
@@ -121,221 +110,68 @@ class TestServerDispatcher {
|
|
|
121
110
|
(0, import_utilsBundle.open)("vscode://file/" + params.location.file + ":" + params.location.line).catch((e) => console.error(e));
|
|
122
111
|
}
|
|
123
112
|
async resizeTerminal(params) {
|
|
124
|
-
|
|
125
|
-
process.stdout.rows = params.rows;
|
|
126
|
-
process.stderr.columns = params.cols;
|
|
127
|
-
process.stderr.rows = params.rows;
|
|
113
|
+
this._testRunner.resizeTerminal(params);
|
|
128
114
|
}
|
|
129
115
|
async checkBrowsers() {
|
|
130
|
-
return { hasBrowsers: hasSomeBrowsers() };
|
|
116
|
+
return { hasBrowsers: this._testRunner.hasSomeBrowsers() };
|
|
131
117
|
}
|
|
132
118
|
async installBrowsers() {
|
|
133
|
-
await installBrowsers();
|
|
119
|
+
await this._testRunner.installBrowsers();
|
|
134
120
|
}
|
|
135
121
|
async runGlobalSetup(params) {
|
|
136
122
|
await this.runGlobalTeardown();
|
|
137
|
-
const { reporter, report } = await this.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return { status: "failed", report };
|
|
141
|
-
const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
|
|
142
|
-
...(0, import_tasks.createGlobalSetupTasks)(config)
|
|
143
|
-
]);
|
|
144
|
-
if (status !== "passed")
|
|
145
|
-
await cleanup();
|
|
146
|
-
else
|
|
147
|
-
this._globalSetup = { cleanup, report };
|
|
123
|
+
const { reporter, report } = await this._collectingReporter();
|
|
124
|
+
this._globalSetupReport = report;
|
|
125
|
+
const { status } = await this._testRunner.runGlobalSetup([reporter, new import_list.default()]);
|
|
148
126
|
return { report, status };
|
|
149
127
|
}
|
|
150
128
|
async runGlobalTeardown() {
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
this.
|
|
154
|
-
return { status, report
|
|
129
|
+
const { status } = await this._testRunner.runGlobalTeardown();
|
|
130
|
+
const report = this._globalSetupReport || [];
|
|
131
|
+
this._globalSetupReport = void 0;
|
|
132
|
+
return { status, report };
|
|
155
133
|
}
|
|
156
134
|
async startDevServer(params) {
|
|
157
135
|
await this.stopDevServer({});
|
|
158
|
-
const { reporter, report } = await this.
|
|
159
|
-
const
|
|
160
|
-
if (!config)
|
|
161
|
-
return { report, status: "failed" };
|
|
162
|
-
const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
|
|
163
|
-
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false }),
|
|
164
|
-
(0, import_tasks.createStartDevServerTask)()
|
|
165
|
-
]);
|
|
166
|
-
if (status !== "passed")
|
|
167
|
-
await cleanup();
|
|
168
|
-
else
|
|
169
|
-
this._devServer = { cleanup, report };
|
|
136
|
+
const { reporter, report } = await this._collectingReporter();
|
|
137
|
+
const { status } = await this._testRunner.startDevServer(reporter, "out-of-process");
|
|
170
138
|
return { report, status };
|
|
171
139
|
}
|
|
172
140
|
async stopDevServer(params) {
|
|
173
|
-
const
|
|
174
|
-
const
|
|
175
|
-
this.
|
|
176
|
-
return { status, report
|
|
141
|
+
const { status } = await this._testRunner.stopDevServer();
|
|
142
|
+
const report = this._devServerReport || [];
|
|
143
|
+
this._devServerReport = void 0;
|
|
144
|
+
return { status, report };
|
|
177
145
|
}
|
|
178
146
|
async clearCache(params) {
|
|
179
|
-
|
|
180
|
-
const config = await this._loadConfigOrReportError(reporter);
|
|
181
|
-
if (!config)
|
|
182
|
-
return;
|
|
183
|
-
await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
184
|
-
(0, import_tasks.createClearCacheTask)(config)
|
|
185
|
-
]);
|
|
147
|
+
await this._testRunner.clearCache();
|
|
186
148
|
}
|
|
187
149
|
async listFiles(params) {
|
|
188
|
-
const { reporter, report } = await this.
|
|
189
|
-
const
|
|
190
|
-
if (!config)
|
|
191
|
-
return { status: "failed", report };
|
|
192
|
-
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
|
|
193
|
-
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
194
|
-
(0, import_tasks.createListFilesTask)(),
|
|
195
|
-
(0, import_tasks.createReportBeginTask)()
|
|
196
|
-
]);
|
|
150
|
+
const { reporter, report } = await this._collectingReporter();
|
|
151
|
+
const { status } = await this._testRunner.listFiles(reporter, params.projects);
|
|
197
152
|
return { report, status };
|
|
198
153
|
}
|
|
199
154
|
async listTests(params) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (config)
|
|
204
|
-
await this._updateWatchedDirs(config);
|
|
205
|
-
result = { report, status };
|
|
206
|
-
}).catch(printInternalError);
|
|
207
|
-
await this._queue;
|
|
208
|
-
return result;
|
|
209
|
-
}
|
|
210
|
-
async _innerListTests(params) {
|
|
211
|
-
const overrides = {
|
|
212
|
-
...this._configCLIOverrides,
|
|
213
|
-
repeatEach: 1,
|
|
214
|
-
retries: 0
|
|
215
|
-
};
|
|
216
|
-
const { reporter, report } = await this._collectingInternalReporter();
|
|
217
|
-
const config = await this._loadConfigOrReportError(reporter, overrides);
|
|
218
|
-
if (!config)
|
|
219
|
-
return { report, reporter, status: "failed" };
|
|
220
|
-
config.cliArgs = params.locations || [];
|
|
221
|
-
config.cliGrep = params.grep;
|
|
222
|
-
config.cliGrepInvert = params.grepInvert;
|
|
223
|
-
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
|
|
224
|
-
config.cliListOnly = true;
|
|
225
|
-
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
226
|
-
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
|
|
227
|
-
(0, import_tasks.createReportBeginTask)()
|
|
228
|
-
]);
|
|
229
|
-
return { config, report, reporter, status };
|
|
230
|
-
}
|
|
231
|
-
async _updateWatchedDirs(config) {
|
|
232
|
-
this._watchedProjectDirs = /* @__PURE__ */ new Set();
|
|
233
|
-
this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
|
|
234
|
-
for (const p of config.projects) {
|
|
235
|
-
this._watchedProjectDirs.add(p.project.testDir);
|
|
236
|
-
this._ignoredProjectOutputs.add(p.project.outputDir);
|
|
237
|
-
}
|
|
238
|
-
const result = await resolveCtDirs(config);
|
|
239
|
-
if (result) {
|
|
240
|
-
this._watchedProjectDirs.add(result.templateDir);
|
|
241
|
-
this._ignoredProjectOutputs.add(result.outDir);
|
|
242
|
-
}
|
|
243
|
-
if (this._watchTestDirs)
|
|
244
|
-
await this._updateWatcher(false);
|
|
245
|
-
}
|
|
246
|
-
async _updateWatcher(reportPending) {
|
|
247
|
-
await this._watcher.update([...this._watchedProjectDirs, ...this._watchedTestDependencies], [...this._ignoredProjectOutputs], reportPending);
|
|
155
|
+
const { reporter, report } = await this._collectingReporter();
|
|
156
|
+
const { status } = await this._testRunner.listTests(reporter, params);
|
|
157
|
+
return { report, status };
|
|
248
158
|
}
|
|
249
159
|
async runTests(params) {
|
|
250
|
-
let result = { status: "passed" };
|
|
251
|
-
this._queue = this._queue.then(async () => {
|
|
252
|
-
result = await this._innerRunTests(params).catch((e) => {
|
|
253
|
-
printInternalError(e);
|
|
254
|
-
return { status: "failed" };
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
await this._queue;
|
|
258
|
-
return result;
|
|
259
|
-
}
|
|
260
|
-
async _innerRunTests(params) {
|
|
261
|
-
await this.stopTests();
|
|
262
|
-
const overrides = {
|
|
263
|
-
...this._configCLIOverrides,
|
|
264
|
-
repeatEach: 1,
|
|
265
|
-
retries: 0,
|
|
266
|
-
preserveOutputDir: true,
|
|
267
|
-
reporter: params.reporters ? params.reporters.map((r) => [r]) : void 0,
|
|
268
|
-
use: {
|
|
269
|
-
...this._configCLIOverrides.use,
|
|
270
|
-
...params.trace === "on" ? { trace: { mode: "on", sources: false, _live: true } } : {},
|
|
271
|
-
...params.trace === "off" ? { trace: "off" } : {},
|
|
272
|
-
...params.video === "on" || params.video === "off" ? { video: params.video } : {},
|
|
273
|
-
...params.headed !== void 0 ? { headless: !params.headed } : {},
|
|
274
|
-
_optionContextReuseMode: params.reuseContext ? "when-possible" : void 0,
|
|
275
|
-
_optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : void 0
|
|
276
|
-
},
|
|
277
|
-
...params.updateSnapshots ? { updateSnapshots: params.updateSnapshots } : {},
|
|
278
|
-
...params.updateSourceMethod ? { updateSourceMethod: params.updateSourceMethod } : {},
|
|
279
|
-
...params.workers ? { workers: params.workers } : {}
|
|
280
|
-
};
|
|
281
|
-
if (params.trace === "on")
|
|
282
|
-
process.env.PW_LIVE_TRACE_STACKS = "1";
|
|
283
|
-
else
|
|
284
|
-
process.env.PW_LIVE_TRACE_STACKS = void 0;
|
|
285
160
|
const wireReporter = await this._wireReporter((e) => this._dispatchEvent("report", e));
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
config.cliArgs = params.locations || [];
|
|
292
|
-
config.cliGrep = params.grep;
|
|
293
|
-
config.cliGrepInvert = params.grepInvert;
|
|
294
|
-
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
|
|
295
|
-
config.preOnlyTestFilters = [];
|
|
296
|
-
if (params.testIds) {
|
|
297
|
-
const testIdSet = new Set(params.testIds);
|
|
298
|
-
config.preOnlyTestFilters.push((test) => testIdSet.has(test.id));
|
|
299
|
-
}
|
|
300
|
-
const configReporters = await (0, import_reporters.createReporters)(config, "test", true);
|
|
301
|
-
const reporter = new import_internalReporter.InternalReporter([...configReporters, wireReporter]);
|
|
302
|
-
const stop = new import_utils.ManualPromise();
|
|
303
|
-
const tasks = [
|
|
304
|
-
(0, import_tasks.createApplyRebaselinesTask)(),
|
|
305
|
-
(0, import_tasks.createLoadTask)("out-of-process", { filterOnly: true, failOnLoadErrors: false, doNotRunDepsOutsideProjectFilter: true }),
|
|
306
|
-
...(0, import_tasks.createRunTestsTasks)(config)
|
|
307
|
-
];
|
|
308
|
-
const run = (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), tasks, 0, stop).then(async (status) => {
|
|
309
|
-
this._testRun = void 0;
|
|
310
|
-
return status;
|
|
311
|
-
});
|
|
312
|
-
this._testRun = { run, stop };
|
|
313
|
-
return { status: await run };
|
|
161
|
+
const { status } = await this._testRunner.runTests(wireReporter, params);
|
|
162
|
+
return { status };
|
|
163
|
+
}
|
|
164
|
+
async resumeAfterStepError(params) {
|
|
165
|
+
await this._testRunner.resumeAfterStepError(params);
|
|
314
166
|
}
|
|
315
167
|
async watch(params) {
|
|
316
|
-
this.
|
|
317
|
-
for (const fileName of params.fileNames) {
|
|
318
|
-
this._watchedTestDependencies.add(fileName);
|
|
319
|
-
(0, import_compilationCache.dependenciesForTestFile)(fileName).forEach((file) => this._watchedTestDependencies.add(file));
|
|
320
|
-
}
|
|
321
|
-
await this._updateWatcher(true);
|
|
168
|
+
await this._testRunner.watch(params.fileNames);
|
|
322
169
|
}
|
|
323
170
|
async findRelatedTestFiles(params) {
|
|
324
|
-
|
|
325
|
-
const reporter = new import_internalReporter.InternalReporter([errorReporter]);
|
|
326
|
-
const config = await this._loadConfigOrReportError(reporter);
|
|
327
|
-
if (!config)
|
|
328
|
-
return { errors: errorReporter.errors(), testFiles: [] };
|
|
329
|
-
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
330
|
-
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false, populateDependencies: true })
|
|
331
|
-
]);
|
|
332
|
-
if (status !== "passed")
|
|
333
|
-
return { errors: errorReporter.errors(), testFiles: [] };
|
|
334
|
-
return { testFiles: (0, import_compilationCache.affectedTestFiles)(params.files) };
|
|
171
|
+
return this._testRunner.findRelatedTestFiles(params.files);
|
|
335
172
|
}
|
|
336
173
|
async stopTests() {
|
|
337
|
-
this.
|
|
338
|
-
await this._testRun?.run;
|
|
174
|
+
await this._testRunner.stopTests();
|
|
339
175
|
}
|
|
340
176
|
async _setInterceptStdio(intercept) {
|
|
341
177
|
if (process.env.PWTEST_DEBUG)
|
|
@@ -347,14 +183,16 @@ class TestServerDispatcher {
|
|
|
347
183
|
return originalStderrWrite.apply(process.stderr, [string]);
|
|
348
184
|
};
|
|
349
185
|
}
|
|
350
|
-
|
|
186
|
+
const stdoutWrite = (chunk) => {
|
|
351
187
|
this._dispatchEvent("stdio", chunkToPayload("stdout", chunk));
|
|
352
188
|
return true;
|
|
353
189
|
};
|
|
354
|
-
|
|
190
|
+
const stderrWrite = (chunk) => {
|
|
355
191
|
this._dispatchEvent("stdio", chunkToPayload("stderr", chunk));
|
|
356
192
|
return true;
|
|
357
193
|
};
|
|
194
|
+
process.stdout.write = stdoutWrite;
|
|
195
|
+
process.stderr.write = stderrWrite;
|
|
358
196
|
} else {
|
|
359
197
|
import_utilsBundle.debug.log = originalDebugLog;
|
|
360
198
|
process.stdout.write = originalStdoutWrite;
|
|
@@ -362,32 +200,7 @@ class TestServerDispatcher {
|
|
|
362
200
|
}
|
|
363
201
|
}
|
|
364
202
|
async closeGracefully() {
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
async _loadConfig(overrides) {
|
|
368
|
-
try {
|
|
369
|
-
const config = await (0, import_configLoader.loadConfig)(this._configLocation, overrides);
|
|
370
|
-
if (!this._plugins) {
|
|
371
|
-
(0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
|
|
372
|
-
(0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
|
|
373
|
-
this._plugins = config.plugins || [];
|
|
374
|
-
} else {
|
|
375
|
-
config.plugins.splice(0, config.plugins.length, ...this._plugins);
|
|
376
|
-
}
|
|
377
|
-
return { config };
|
|
378
|
-
} catch (e) {
|
|
379
|
-
return { config: null, error: (0, import_util2.serializeError)(e) };
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
async _loadConfigOrReportError(reporter, overrides) {
|
|
383
|
-
const { config, error } = await this._loadConfig(overrides);
|
|
384
|
-
if (config)
|
|
385
|
-
return config;
|
|
386
|
-
reporter.onConfigure(import_teleReceiver.baseFullConfig);
|
|
387
|
-
reporter.onError(error);
|
|
388
|
-
await reporter.onEnd({ status: "failed" });
|
|
389
|
-
await reporter.onExit();
|
|
390
|
-
return null;
|
|
203
|
+
await this._testRunner.closeGracefully();
|
|
391
204
|
}
|
|
392
205
|
}
|
|
393
206
|
async function runUIMode(configFile, configCLIOverrides, options) {
|
|
@@ -448,39 +261,10 @@ function chunkToPayload(type, chunk) {
|
|
|
448
261
|
return { type, buffer: chunk.toString("base64") };
|
|
449
262
|
return { type, text: chunk };
|
|
450
263
|
}
|
|
451
|
-
function hasSomeBrowsers() {
|
|
452
|
-
for (const browserName of ["chromium", "webkit", "firefox"]) {
|
|
453
|
-
try {
|
|
454
|
-
import_server.registry.findExecutable(browserName).executablePathOrDie("javascript");
|
|
455
|
-
return true;
|
|
456
|
-
} catch {
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
return false;
|
|
460
|
-
}
|
|
461
|
-
async function installBrowsers() {
|
|
462
|
-
const executables = import_server.registry.defaultExecutables();
|
|
463
|
-
await import_server.registry.install(executables, false);
|
|
464
|
-
}
|
|
465
|
-
function printInternalError(e) {
|
|
466
|
-
console.error("Internal error:", e);
|
|
467
|
-
}
|
|
468
|
-
async function resolveCtDirs(config) {
|
|
469
|
-
const use = config.config.projects[0].use;
|
|
470
|
-
const relativeTemplateDir = use.ctTemplateDir || "playwright";
|
|
471
|
-
const templateDir = await import_fs.default.promises.realpath(import_path.default.normalize(import_path.default.join(config.configDir, relativeTemplateDir))).catch(() => void 0);
|
|
472
|
-
if (!templateDir)
|
|
473
|
-
return null;
|
|
474
|
-
const outDir = use.ctCacheDir ? import_path.default.resolve(config.configDir, use.ctCacheDir) : import_path.default.resolve(templateDir, ".cache");
|
|
475
|
-
return {
|
|
476
|
-
outDir,
|
|
477
|
-
templateDir
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
264
|
// Annotate the CommonJS export names for ESM import in node:
|
|
481
265
|
0 && (module.exports = {
|
|
266
|
+
TestRunnerEvent,
|
|
482
267
|
TestServerDispatcher,
|
|
483
|
-
resolveCtDirs,
|
|
484
268
|
runTestServer,
|
|
485
269
|
runUIMode
|
|
486
270
|
});
|
package/lib/runner/watchMode.js
CHANGED
|
@@ -31,6 +31,7 @@ __export(watchMode_exports, {
|
|
|
31
31
|
runWatchModeLoop: () => runWatchModeLoop
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(watchMode_exports);
|
|
34
|
+
var import_fs = __toESM(require("fs"));
|
|
34
35
|
var import_path = __toESM(require("path"));
|
|
35
36
|
var import_readline = __toESM(require("readline"));
|
|
36
37
|
var import_stream = require("stream");
|
|
@@ -42,6 +43,8 @@ var import_utilsBundle = require("../utilsBundle");
|
|
|
42
43
|
var import_testServer = require("./testServer");
|
|
43
44
|
var import_teleSuiteUpdater = require("../isomorphic/teleSuiteUpdater");
|
|
44
45
|
var import_testServerConnection = require("../isomorphic/testServerConnection");
|
|
46
|
+
var import_util = require("../util");
|
|
47
|
+
var import_babelBundle = require("../transform/babelBundle");
|
|
45
48
|
class InMemoryTransport extends import_stream.EventEmitter {
|
|
46
49
|
constructor(send) {
|
|
47
50
|
super();
|
|
@@ -113,7 +116,37 @@ async function runWatchModeLoop(configLocation, initialOptions) {
|
|
|
113
116
|
});
|
|
114
117
|
});
|
|
115
118
|
testServerConnection.onReport((report2) => teleSuiteUpdater.processTestReportEvent(report2));
|
|
116
|
-
|
|
119
|
+
testServerConnection.onRecoverFromStepError(({ stepId, message, location }) => {
|
|
120
|
+
process.stdout.write(`
|
|
121
|
+
Test error occurred.
|
|
122
|
+
`);
|
|
123
|
+
process.stdout.write("\n" + createErrorCodeframe(message, location) + "\n");
|
|
124
|
+
process.stdout.write(`
|
|
125
|
+
${import_utils2.colors.dim("Try recovering from the error. Press")} ${import_utils2.colors.bold("c")} ${import_utils2.colors.dim("to continue or")} ${import_utils2.colors.bold("t")} ${import_utils2.colors.dim("to throw the error")}
|
|
126
|
+
`);
|
|
127
|
+
readKeyPress((text) => {
|
|
128
|
+
if (text === "c") {
|
|
129
|
+
process.stdout.write(`
|
|
130
|
+
${import_utils2.colors.dim("Continuing after recovery...")}
|
|
131
|
+
`);
|
|
132
|
+
testServerConnection.resumeAfterStepError({ stepId, status: "recovered", value: void 0 }).catch(() => {
|
|
133
|
+
});
|
|
134
|
+
} else if (text === "t") {
|
|
135
|
+
process.stdout.write(`
|
|
136
|
+
${import_utils2.colors.dim("Throwing error...")}
|
|
137
|
+
`);
|
|
138
|
+
testServerConnection.resumeAfterStepError({ stepId, status: "failed" }).catch(() => {
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return text;
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
await testServerConnection.initialize({
|
|
145
|
+
interceptStdio: false,
|
|
146
|
+
watchTestDirs: true,
|
|
147
|
+
populateDependenciesOnList: true,
|
|
148
|
+
recoverFromStepErrors: !process.env.PWTEST_RECOVERY_DISABLED
|
|
149
|
+
});
|
|
117
150
|
await testServerConnection.runGlobalSetup({});
|
|
118
151
|
const { report } = await testServerConnection.listTests({});
|
|
119
152
|
teleSuiteUpdater.processListReport(report);
|
|
@@ -385,6 +418,29 @@ async function toggleShowBrowser() {
|
|
|
385
418
|
`);
|
|
386
419
|
}
|
|
387
420
|
}
|
|
421
|
+
function createErrorCodeframe(message, location) {
|
|
422
|
+
let source;
|
|
423
|
+
try {
|
|
424
|
+
source = import_fs.default.readFileSync(location.file, "utf-8") + "\n//";
|
|
425
|
+
} catch (e) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
return (0, import_babelBundle.codeFrameColumns)(
|
|
429
|
+
source,
|
|
430
|
+
{
|
|
431
|
+
start: {
|
|
432
|
+
line: location.line,
|
|
433
|
+
column: location.column
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
highlightCode: true,
|
|
438
|
+
linesAbove: 5,
|
|
439
|
+
linesBelow: 5,
|
|
440
|
+
message: (0, import_util.stripAnsiEscapes)(message).split("\n")[0] || void 0
|
|
441
|
+
}
|
|
442
|
+
);
|
|
443
|
+
}
|
|
388
444
|
// Annotate the CommonJS export names for ESM import in node:
|
|
389
445
|
0 && (module.exports = {
|
|
390
446
|
runWatchModeLoop
|
package/lib/runner/workerHost.js
CHANGED
|
@@ -39,7 +39,7 @@ var import_ipc = require("../common/ipc");
|
|
|
39
39
|
var import_folders = require("../isomorphic/folders");
|
|
40
40
|
let lastWorkerIndex = 0;
|
|
41
41
|
class WorkerHost extends import_processHost.ProcessHost {
|
|
42
|
-
constructor(testGroup, parallelIndex, config, extraEnv, outputDir) {
|
|
42
|
+
constructor(testGroup, parallelIndex, config, recoverFromStepErrors, extraEnv, outputDir) {
|
|
43
43
|
const workerIndex = lastWorkerIndex++;
|
|
44
44
|
super(require.resolve("../worker/workerMain.js"), `worker-${workerIndex}`, {
|
|
45
45
|
...extraEnv,
|
|
@@ -56,7 +56,8 @@ class WorkerHost extends import_processHost.ProcessHost {
|
|
|
56
56
|
repeatEachIndex: testGroup.repeatEachIndex,
|
|
57
57
|
projectId: testGroup.projectId,
|
|
58
58
|
config,
|
|
59
|
-
artifactsDir: import_path.default.join(outputDir, (0, import_folders.artifactsFolderName)(workerIndex))
|
|
59
|
+
artifactsDir: import_path.default.join(outputDir, (0, import_folders.artifactsFolderName)(workerIndex)),
|
|
60
|
+
recoverFromStepErrors
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
async start() {
|
|
@@ -77,6 +78,9 @@ class WorkerHost extends import_processHost.ProcessHost {
|
|
|
77
78
|
runTestGroup(runPayload) {
|
|
78
79
|
this.sendMessageNoReply({ method: "runTestGroup", params: runPayload });
|
|
79
80
|
}
|
|
81
|
+
resumeAfterStepError(result) {
|
|
82
|
+
this.sendMessageNoReply({ method: "resumeAfterStepError", params: result });
|
|
83
|
+
}
|
|
80
84
|
hash() {
|
|
81
85
|
return this._hash;
|
|
82
86
|
}
|
|
@@ -40,11 +40,11 @@ __export(transform_exports, {
|
|
|
40
40
|
wrapFunctionWithLocation: () => wrapFunctionWithLocation
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(transform_exports);
|
|
43
|
-
var import_crypto = __toESM(require("crypto"));
|
|
44
43
|
var import_fs = __toESM(require("fs"));
|
|
45
44
|
var import_module = __toESM(require("module"));
|
|
46
45
|
var import_path = __toESM(require("path"));
|
|
47
46
|
var import_url = __toESM(require("url"));
|
|
47
|
+
var import_crypto = __toESM(require("crypto"));
|
|
48
48
|
var import_tsconfig_loader = require("../third_party/tsconfig-loader");
|
|
49
49
|
var import_util = require("../util");
|
|
50
50
|
var import_utilsBundle = require("../utilsBundle");
|
package/lib/util.js
CHANGED
|
@@ -47,7 +47,6 @@ __export(util_exports, {
|
|
|
47
47
|
formatLocation: () => formatLocation,
|
|
48
48
|
getContainedPath: () => getContainedPath,
|
|
49
49
|
getPackageJsonPath: () => getPackageJsonPath,
|
|
50
|
-
loadTestFilterFile: () => loadTestFilterFile,
|
|
51
50
|
mergeObjects: () => mergeObjects,
|
|
52
51
|
normalizeAndSaveAttachment: () => normalizeAndSaveAttachment,
|
|
53
52
|
relativeFilePath: () => relativeFilePath,
|
|
@@ -373,22 +372,6 @@ const ansiRegex = new RegExp("([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*
|
|
|
373
372
|
function stripAnsiEscapes(str) {
|
|
374
373
|
return str.replace(ansiRegex, "");
|
|
375
374
|
}
|
|
376
|
-
async function loadTestFilterFile(filePath) {
|
|
377
|
-
try {
|
|
378
|
-
const data = JSON.parse(await import_fs.default.promises.readFile(filePath, "utf8"));
|
|
379
|
-
if (!data || typeof data !== "object" || !Array.isArray(data.titlePath) || !data.titlePath.every((path2) => Array.isArray(path2)))
|
|
380
|
-
throw new Error(`Wrong test filter file format`);
|
|
381
|
-
const toId = (titlePath) => {
|
|
382
|
-
const [project, file, ...titles] = titlePath;
|
|
383
|
-
return `${project}${(0, import_utils.toPosixPath)(file)}${titles.join("")}`;
|
|
384
|
-
};
|
|
385
|
-
const ids = new Set(data.titlePath.map((titlePath) => toId(titlePath)));
|
|
386
|
-
return (test) => ids.has(toId(test.titlePath()));
|
|
387
|
-
} catch (error) {
|
|
388
|
-
(0, import_utils.rewriteErrorMessage)(error, `Failed to read test filter file "${filePath}": ${error.message}`);
|
|
389
|
-
throw error;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
375
|
// Annotate the CommonJS export names for ESM import in node:
|
|
393
376
|
0 && (module.exports = {
|
|
394
377
|
addSuffixToFilePath,
|
|
@@ -410,7 +393,6 @@ async function loadTestFilterFile(filePath) {
|
|
|
410
393
|
formatLocation,
|
|
411
394
|
getContainedPath,
|
|
412
395
|
getPackageJsonPath,
|
|
413
|
-
loadTestFilterFile,
|
|
414
396
|
mergeObjects,
|
|
415
397
|
normalizeAndSaveAttachment,
|
|
416
398
|
relativeFilePath,
|
package/lib/worker/testInfo.js
CHANGED
|
@@ -43,7 +43,7 @@ var import_testTracing = require("./testTracing");
|
|
|
43
43
|
var import_util2 = require("./util");
|
|
44
44
|
var import_transform = require("../transform/transform");
|
|
45
45
|
class TestInfoImpl {
|
|
46
|
-
constructor(configInternal, projectInternal, workerParams, test, retry, onStepBegin, onStepEnd, onAttach) {
|
|
46
|
+
constructor(configInternal, projectInternal, workerParams, test, retry, onStepBegin, onStepRecoverFromError, onStepEnd, onAttach) {
|
|
47
47
|
this._snapshotNames = { lastAnonymousSnapshotIndex: 0, lastNamedSnapshotIndex: {} };
|
|
48
48
|
this._ariaSnapshotNames = { lastAnonymousSnapshotIndex: 0, lastNamedSnapshotIndex: {} };
|
|
49
49
|
this._wasInterrupted = false;
|
|
@@ -61,6 +61,7 @@ class TestInfoImpl {
|
|
|
61
61
|
this.errors = [];
|
|
62
62
|
this.testId = test?.id ?? "";
|
|
63
63
|
this._onStepBegin = onStepBegin;
|
|
64
|
+
this._onStepRecoverFromError = onStepRecoverFromError;
|
|
64
65
|
this._onStepEnd = onStepEnd;
|
|
65
66
|
this._onAttach = onAttach;
|
|
66
67
|
this._startTime = (0, import_utils.monotonicTime)();
|
|
@@ -84,6 +85,7 @@ class TestInfoImpl {
|
|
|
84
85
|
this.fn = test?.fn ?? (() => {
|
|
85
86
|
});
|
|
86
87
|
this.expectedStatus = test?.expectedStatus ?? "skipped";
|
|
88
|
+
this._recoverFromStepErrorResults = workerParams.recoverFromStepErrors ? /* @__PURE__ */ new Map() : void 0;
|
|
87
89
|
this._timeoutManager = new import_timeoutManager.TimeoutManager(this.project.timeout);
|
|
88
90
|
if (configInternal.configCLIOverrides.debug)
|
|
89
91
|
this._setDebugMode();
|
|
@@ -202,6 +204,22 @@ class TestInfoImpl {
|
|
|
202
204
|
steps: [],
|
|
203
205
|
attachmentIndices: [],
|
|
204
206
|
info: new TestStepInfoImpl(this, stepId, data.title, parentStep?.info),
|
|
207
|
+
recoverFromStepError: async (error) => {
|
|
208
|
+
if (!this._recoverFromStepErrorResults)
|
|
209
|
+
return { stepId, status: "failed" };
|
|
210
|
+
const payload = {
|
|
211
|
+
testId: this.testId,
|
|
212
|
+
stepId,
|
|
213
|
+
error: (0, import_util.serializeError)(error)
|
|
214
|
+
};
|
|
215
|
+
this._onStepRecoverFromError(payload);
|
|
216
|
+
const recoveryPromise = new import_utils.ManualPromise();
|
|
217
|
+
this._recoverFromStepErrorResults.set(stepId, recoveryPromise);
|
|
218
|
+
const recoveryResult = await recoveryPromise;
|
|
219
|
+
if (recoveryResult.stepId !== stepId)
|
|
220
|
+
return { stepId, status: "failed" };
|
|
221
|
+
return recoveryResult;
|
|
222
|
+
},
|
|
205
223
|
complete: (result) => {
|
|
206
224
|
if (step.endWallTime)
|
|
207
225
|
return;
|
|
@@ -270,6 +288,11 @@ ${(0, import_utils.stringifyStackFrames)(step.boxedStack).join("\n")}`;
|
|
|
270
288
|
}
|
|
271
289
|
return step;
|
|
272
290
|
}
|
|
291
|
+
resumeAfterStepError(result) {
|
|
292
|
+
const recoveryPromise = this._recoverFromStepErrorResults?.get(result.stepId);
|
|
293
|
+
if (recoveryPromise)
|
|
294
|
+
recoveryPromise.resolve(result);
|
|
295
|
+
}
|
|
273
296
|
_interrupt() {
|
|
274
297
|
this._wasInterrupted = true;
|
|
275
298
|
this._timeoutManager.interrupt();
|