@ohos-ports/playwright 1.52.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +168 -0
- package/ThirdPartyNotices.txt +4011 -0
- package/cli.js +19 -0
- package/index.d.ts +17 -0
- package/index.js +17 -0
- package/index.mjs +18 -0
- package/jsx-runtime.js +42 -0
- package/jsx-runtime.mjs +21 -0
- package/lib/common/config.js +272 -0
- package/lib/common/configLoader.js +373 -0
- package/lib/common/esmLoaderHost.js +100 -0
- package/lib/common/expectBundle.js +49 -0
- package/lib/common/expectBundleImpl.js +389 -0
- package/lib/common/fixtures.js +302 -0
- package/lib/common/globals.js +58 -0
- package/lib/common/ipc.js +60 -0
- package/lib/common/poolBuilder.js +85 -0
- package/lib/common/process.js +109 -0
- package/lib/common/suiteUtils.js +149 -0
- package/lib/common/test.js +313 -0
- package/lib/common/testLoader.js +100 -0
- package/lib/common/testType.js +306 -0
- package/lib/errorContext.js +149 -0
- package/lib/fsWatcher.js +67 -0
- package/lib/index.js +692 -0
- package/lib/internalsForTest.js +42 -0
- package/lib/isomorphic/events.js +77 -0
- package/lib/isomorphic/folders.js +30 -0
- package/lib/isomorphic/stringInternPool.js +69 -0
- package/lib/isomorphic/teleReceiver.js +484 -0
- package/lib/isomorphic/teleSuiteUpdater.js +137 -0
- package/lib/isomorphic/testServerConnection.js +211 -0
- package/lib/isomorphic/testServerInterface.js +16 -0
- package/lib/isomorphic/testTree.js +307 -0
- package/lib/isomorphic/types.d.js +16 -0
- package/lib/isomorphic/util.js +28 -0
- package/lib/loader/loaderMain.js +59 -0
- package/lib/matchers/expect.js +322 -0
- package/lib/matchers/matcherHint.js +59 -0
- package/lib/matchers/matchers.js +362 -0
- package/lib/matchers/toBeTruthy.js +71 -0
- package/lib/matchers/toEqual.js +94 -0
- package/lib/matchers/toHaveURL.js +117 -0
- package/lib/matchers/toMatchAriaSnapshot.js +180 -0
- package/lib/matchers/toMatchSnapshot.js +365 -0
- package/lib/matchers/toMatchText.js +105 -0
- package/lib/plugins/gitCommitInfoPlugin.js +198 -0
- package/lib/plugins/index.js +28 -0
- package/lib/plugins/webServerPlugin.js +207 -0
- package/lib/program.js +407 -0
- package/lib/reporters/base.js +540 -0
- package/lib/reporters/blob.js +135 -0
- package/lib/reporters/dot.js +82 -0
- package/lib/reporters/empty.js +32 -0
- package/lib/reporters/github.js +127 -0
- package/lib/reporters/html.js +579 -0
- package/lib/reporters/internalReporter.js +129 -0
- package/lib/reporters/json.js +254 -0
- package/lib/reporters/junit.js +230 -0
- package/lib/reporters/line.js +113 -0
- package/lib/reporters/list.js +228 -0
- package/lib/reporters/merge.js +511 -0
- package/lib/reporters/multiplexer.js +104 -0
- package/lib/reporters/reporterV2.js +102 -0
- package/lib/reporters/teleEmitter.js +269 -0
- package/lib/reporters/versions/blobV1.js +16 -0
- package/lib/runner/dispatcher.js +484 -0
- package/lib/runner/failureTracker.js +62 -0
- package/lib/runner/lastRun.js +74 -0
- package/lib/runner/loadUtils.js +299 -0
- package/lib/runner/loaderHost.js +89 -0
- package/lib/runner/processHost.js +165 -0
- package/lib/runner/projectUtils.js +235 -0
- package/lib/runner/rebase.js +189 -0
- package/lib/runner/reporters.js +162 -0
- package/lib/runner/runner.js +110 -0
- package/lib/runner/sigIntWatcher.js +96 -0
- package/lib/runner/taskRunner.js +127 -0
- package/lib/runner/tasks.js +400 -0
- package/lib/runner/testGroups.js +117 -0
- package/lib/runner/testServer.js +477 -0
- package/lib/runner/uiModeReporter.js +30 -0
- package/lib/runner/vcs.js +72 -0
- package/lib/runner/watchMode.js +394 -0
- package/lib/runner/workerHost.js +93 -0
- package/lib/third_party/tsconfig-loader.js +103 -0
- package/lib/transform/babelBundle.js +43 -0
- package/lib/transform/babelBundleImpl.js +477 -0
- package/lib/transform/compilationCache.js +255 -0
- package/lib/transform/esmLoader.js +104 -0
- package/lib/transform/esmUtils.js +53 -0
- package/lib/transform/portTransport.js +66 -0
- package/lib/transform/transform.js +291 -0
- package/lib/util.js +407 -0
- package/lib/utilsBundle.js +46 -0
- package/lib/utilsBundleImpl.js +102 -0
- package/lib/worker/fixtureRunner.js +253 -0
- package/lib/worker/testInfo.js +422 -0
- package/lib/worker/testTracing.js +351 -0
- package/lib/worker/timeoutManager.js +174 -0
- package/lib/worker/util.js +31 -0
- package/lib/worker/workerMain.js +511 -0
- package/package.json +64 -0
- package/test.d.ts +18 -0
- package/test.js +24 -0
- package/test.mjs +33 -0
- package/types/test.d.ts +10061 -0
- package/types/testReporter.d.ts +799 -0
|
@@ -0,0 +1,477 @@
|
|
|
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 testServer_exports = {};
|
|
30
|
+
__export(testServer_exports, {
|
|
31
|
+
TestServerDispatcher: () => TestServerDispatcher,
|
|
32
|
+
resolveCtDirs: () => resolveCtDirs,
|
|
33
|
+
runTestServer: () => runTestServer,
|
|
34
|
+
runUIMode: () => runUIMode
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(testServer_exports);
|
|
37
|
+
var import_fs = __toESM(require("fs"));
|
|
38
|
+
var import_path = __toESM(require("path"));
|
|
39
|
+
var import_server = require("@ohos-ports/playwright-core/lib/server");
|
|
40
|
+
var import_utils = require("@ohos-ports/playwright-core/lib/utils");
|
|
41
|
+
var import_utilsBundle = require("@ohos-ports/playwright-core/lib/utilsBundle");
|
|
42
|
+
var import_reporters = require("./reporters");
|
|
43
|
+
var import_sigIntWatcher = require("./sigIntWatcher");
|
|
44
|
+
var import_tasks = require("./tasks");
|
|
45
|
+
var import_configLoader = require("../common/configLoader");
|
|
46
|
+
var import_fsWatcher = require("../fsWatcher");
|
|
47
|
+
var import_teleReceiver = require("../isomorphic/teleReceiver");
|
|
48
|
+
var import_gitCommitInfoPlugin = require("../plugins/gitCommitInfoPlugin");
|
|
49
|
+
var import_webServerPlugin = require("../plugins/webServerPlugin");
|
|
50
|
+
var import_base = require("../reporters/base");
|
|
51
|
+
var import_internalReporter = require("../reporters/internalReporter");
|
|
52
|
+
var import_list = __toESM(require("../reporters/list"));
|
|
53
|
+
var import_compilationCache = require("../transform/compilationCache");
|
|
54
|
+
var import_util = require("../util");
|
|
55
|
+
const originalStdoutWrite = process.stdout.write;
|
|
56
|
+
const originalStderrWrite = process.stderr.write;
|
|
57
|
+
class TestServer {
|
|
58
|
+
constructor(configLocation, configCLIOverrides) {
|
|
59
|
+
this._configLocation = configLocation;
|
|
60
|
+
this._configCLIOverrides = configCLIOverrides;
|
|
61
|
+
}
|
|
62
|
+
async start(options) {
|
|
63
|
+
this._dispatcher = new TestServerDispatcher(this._configLocation, this._configCLIOverrides);
|
|
64
|
+
return await (0, import_server.startTraceViewerServer)({ ...options, transport: this._dispatcher.transport });
|
|
65
|
+
}
|
|
66
|
+
async stop() {
|
|
67
|
+
await this._dispatcher?._setInterceptStdio(false);
|
|
68
|
+
await this._dispatcher?.runGlobalTeardown();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
class TestServerDispatcher {
|
|
72
|
+
constructor(configLocation, configCLIOverrides) {
|
|
73
|
+
this._watchedProjectDirs = /* @__PURE__ */ new Set();
|
|
74
|
+
this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
|
|
75
|
+
this._watchedTestDependencies = /* @__PURE__ */ new Set();
|
|
76
|
+
this._queue = Promise.resolve();
|
|
77
|
+
this._serializer = require.resolve("./uiModeReporter");
|
|
78
|
+
this._watchTestDirs = false;
|
|
79
|
+
this._closeOnDisconnect = false;
|
|
80
|
+
this._populateDependenciesOnList = false;
|
|
81
|
+
this._configLocation = configLocation;
|
|
82
|
+
this._configCLIOverrides = configCLIOverrides;
|
|
83
|
+
this.transport = {
|
|
84
|
+
onconnect: () => {
|
|
85
|
+
},
|
|
86
|
+
dispatch: (method, params) => this[method](params),
|
|
87
|
+
onclose: () => {
|
|
88
|
+
if (this._closeOnDisconnect)
|
|
89
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(0);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
this._watcher = new import_fsWatcher.Watcher((events) => {
|
|
93
|
+
const collector = /* @__PURE__ */ new Set();
|
|
94
|
+
events.forEach((f) => (0, import_compilationCache.collectAffectedTestFiles)(f.file, collector));
|
|
95
|
+
this._dispatchEvent("testFilesChanged", { testFiles: [...collector] });
|
|
96
|
+
});
|
|
97
|
+
this._dispatchEvent = (method, params) => this.transport.sendEvent?.(method, params);
|
|
98
|
+
}
|
|
99
|
+
async _wireReporter(messageSink) {
|
|
100
|
+
return await (0, import_reporters.createReporterForTestServer)(this._serializer, messageSink);
|
|
101
|
+
}
|
|
102
|
+
async _collectingInternalReporter(...extraReporters) {
|
|
103
|
+
const report = [];
|
|
104
|
+
const collectingReporter = await (0, import_reporters.createReporterForTestServer)(this._serializer, (e) => report.push(e));
|
|
105
|
+
return { reporter: new import_internalReporter.InternalReporter([collectingReporter, ...extraReporters]), report };
|
|
106
|
+
}
|
|
107
|
+
async initialize(params) {
|
|
108
|
+
this._serializer = params.serializer || require.resolve("./uiModeReporter");
|
|
109
|
+
this._closeOnDisconnect = !!params.closeOnDisconnect;
|
|
110
|
+
await this._setInterceptStdio(!!params.interceptStdio);
|
|
111
|
+
this._watchTestDirs = !!params.watchTestDirs;
|
|
112
|
+
this._populateDependenciesOnList = !!params.populateDependenciesOnList;
|
|
113
|
+
}
|
|
114
|
+
async ping() {
|
|
115
|
+
}
|
|
116
|
+
async open(params) {
|
|
117
|
+
if ((0, import_utils.isUnderTest)())
|
|
118
|
+
return;
|
|
119
|
+
(0, import_utilsBundle.open)("vscode://file/" + params.location.file + ":" + params.location.line).catch((e) => console.error(e));
|
|
120
|
+
}
|
|
121
|
+
async resizeTerminal(params) {
|
|
122
|
+
process.stdout.columns = params.cols;
|
|
123
|
+
process.stdout.rows = params.rows;
|
|
124
|
+
process.stderr.columns = params.cols;
|
|
125
|
+
process.stderr.columns = params.rows;
|
|
126
|
+
}
|
|
127
|
+
async checkBrowsers() {
|
|
128
|
+
return { hasBrowsers: hasSomeBrowsers() };
|
|
129
|
+
}
|
|
130
|
+
async installBrowsers() {
|
|
131
|
+
await installBrowsers();
|
|
132
|
+
}
|
|
133
|
+
async runGlobalSetup(params) {
|
|
134
|
+
await this.runGlobalTeardown();
|
|
135
|
+
const { reporter, report } = await this._collectingInternalReporter(new import_list.default());
|
|
136
|
+
const config = await this._loadConfigOrReportError(reporter, this._configCLIOverrides);
|
|
137
|
+
if (!config)
|
|
138
|
+
return { status: "failed", report };
|
|
139
|
+
const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
|
|
140
|
+
...(0, import_tasks.createGlobalSetupTasks)(config)
|
|
141
|
+
]);
|
|
142
|
+
if (status !== "passed")
|
|
143
|
+
await cleanup();
|
|
144
|
+
else
|
|
145
|
+
this._globalSetup = { cleanup, report };
|
|
146
|
+
return { report, status };
|
|
147
|
+
}
|
|
148
|
+
async runGlobalTeardown() {
|
|
149
|
+
const globalSetup = this._globalSetup;
|
|
150
|
+
const status = await globalSetup?.cleanup();
|
|
151
|
+
this._globalSetup = void 0;
|
|
152
|
+
return { status, report: globalSetup?.report || [] };
|
|
153
|
+
}
|
|
154
|
+
async startDevServer(params) {
|
|
155
|
+
await this.stopDevServer({});
|
|
156
|
+
const { reporter, report } = await this._collectingInternalReporter();
|
|
157
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
158
|
+
if (!config)
|
|
159
|
+
return { report, status: "failed" };
|
|
160
|
+
const { status, cleanup } = await (0, import_tasks.runTasksDeferCleanup)(new import_tasks.TestRun(config, reporter), [
|
|
161
|
+
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false }),
|
|
162
|
+
(0, import_tasks.createStartDevServerTask)()
|
|
163
|
+
]);
|
|
164
|
+
if (status !== "passed")
|
|
165
|
+
await cleanup();
|
|
166
|
+
else
|
|
167
|
+
this._devServer = { cleanup, report };
|
|
168
|
+
return { report, status };
|
|
169
|
+
}
|
|
170
|
+
async stopDevServer(params) {
|
|
171
|
+
const devServer = this._devServer;
|
|
172
|
+
const status = await devServer?.cleanup();
|
|
173
|
+
this._devServer = void 0;
|
|
174
|
+
return { status, report: devServer?.report || [] };
|
|
175
|
+
}
|
|
176
|
+
async clearCache(params) {
|
|
177
|
+
const reporter = new import_internalReporter.InternalReporter([]);
|
|
178
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
179
|
+
if (!config)
|
|
180
|
+
return;
|
|
181
|
+
await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
182
|
+
(0, import_tasks.createClearCacheTask)(config)
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
async listFiles(params) {
|
|
186
|
+
const { reporter, report } = await this._collectingInternalReporter();
|
|
187
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
188
|
+
if (!config)
|
|
189
|
+
return { status: "failed", report };
|
|
190
|
+
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
|
|
191
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
192
|
+
(0, import_tasks.createListFilesTask)(),
|
|
193
|
+
(0, import_tasks.createReportBeginTask)()
|
|
194
|
+
]);
|
|
195
|
+
return { report, status };
|
|
196
|
+
}
|
|
197
|
+
async listTests(params) {
|
|
198
|
+
let result;
|
|
199
|
+
this._queue = this._queue.then(async () => {
|
|
200
|
+
const { config, report, status } = await this._innerListTests(params);
|
|
201
|
+
if (config)
|
|
202
|
+
await this._updateWatchedDirs(config);
|
|
203
|
+
result = { report, status };
|
|
204
|
+
}).catch(printInternalError);
|
|
205
|
+
await this._queue;
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
async _innerListTests(params) {
|
|
209
|
+
const overrides = {
|
|
210
|
+
...this._configCLIOverrides,
|
|
211
|
+
repeatEach: 1,
|
|
212
|
+
retries: 0
|
|
213
|
+
};
|
|
214
|
+
const { reporter, report } = await this._collectingInternalReporter();
|
|
215
|
+
const config = await this._loadConfigOrReportError(reporter, overrides);
|
|
216
|
+
if (!config)
|
|
217
|
+
return { report, reporter, status: "failed" };
|
|
218
|
+
config.cliArgs = params.locations || [];
|
|
219
|
+
config.cliGrep = params.grep;
|
|
220
|
+
config.cliGrepInvert = params.grepInvert;
|
|
221
|
+
config.cliProjectFilter = params.projects?.length ? params.projects : void 0;
|
|
222
|
+
config.cliListOnly = true;
|
|
223
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
224
|
+
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: false, filterOnly: false, populateDependencies: this._populateDependenciesOnList }),
|
|
225
|
+
(0, import_tasks.createReportBeginTask)()
|
|
226
|
+
]);
|
|
227
|
+
return { config, report, reporter, status };
|
|
228
|
+
}
|
|
229
|
+
async _updateWatchedDirs(config) {
|
|
230
|
+
this._watchedProjectDirs = /* @__PURE__ */ new Set();
|
|
231
|
+
this._ignoredProjectOutputs = /* @__PURE__ */ new Set();
|
|
232
|
+
for (const p of config.projects) {
|
|
233
|
+
this._watchedProjectDirs.add(p.project.testDir);
|
|
234
|
+
this._ignoredProjectOutputs.add(p.project.outputDir);
|
|
235
|
+
}
|
|
236
|
+
const result = await resolveCtDirs(config);
|
|
237
|
+
if (result) {
|
|
238
|
+
this._watchedProjectDirs.add(result.templateDir);
|
|
239
|
+
this._ignoredProjectOutputs.add(result.outDir);
|
|
240
|
+
}
|
|
241
|
+
if (this._watchTestDirs)
|
|
242
|
+
await this._updateWatcher(false);
|
|
243
|
+
}
|
|
244
|
+
async _updateWatcher(reportPending) {
|
|
245
|
+
await this._watcher.update([...this._watchedProjectDirs, ...this._watchedTestDependencies], [...this._ignoredProjectOutputs], reportPending);
|
|
246
|
+
}
|
|
247
|
+
async runTests(params) {
|
|
248
|
+
let result = { status: "passed" };
|
|
249
|
+
this._queue = this._queue.then(async () => {
|
|
250
|
+
result = await this._innerRunTests(params).catch((e) => {
|
|
251
|
+
printInternalError(e);
|
|
252
|
+
return { status: "failed" };
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
await this._queue;
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
async _innerRunTests(params) {
|
|
259
|
+
await this.stopTests();
|
|
260
|
+
const overrides = {
|
|
261
|
+
...this._configCLIOverrides,
|
|
262
|
+
repeatEach: 1,
|
|
263
|
+
retries: 0,
|
|
264
|
+
preserveOutputDir: true,
|
|
265
|
+
reporter: params.reporters ? params.reporters.map((r) => [r]) : void 0,
|
|
266
|
+
use: {
|
|
267
|
+
...this._configCLIOverrides.use,
|
|
268
|
+
...params.trace === "on" ? { trace: { mode: "on", sources: false, _live: true } } : {},
|
|
269
|
+
...params.trace === "off" ? { trace: "off" } : {},
|
|
270
|
+
...params.video === "on" || params.video === "off" ? { video: params.video } : {},
|
|
271
|
+
...params.headed !== void 0 ? { headless: !params.headed } : {},
|
|
272
|
+
_optionContextReuseMode: params.reuseContext ? "when-possible" : void 0,
|
|
273
|
+
_optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : void 0,
|
|
274
|
+
_optionErrorContext: params.errorContext
|
|
275
|
+
},
|
|
276
|
+
...params.updateSnapshots ? { updateSnapshots: params.updateSnapshots } : {},
|
|
277
|
+
...params.updateSourceMethod ? { updateSourceMethod: params.updateSourceMethod } : {},
|
|
278
|
+
...params.workers ? { workers: params.workers } : {}
|
|
279
|
+
};
|
|
280
|
+
if (params.trace === "on")
|
|
281
|
+
process.env.PW_LIVE_TRACE_STACKS = "1";
|
|
282
|
+
else
|
|
283
|
+
process.env.PW_LIVE_TRACE_STACKS = void 0;
|
|
284
|
+
const wireReporter = await this._wireReporter((e) => this._dispatchEvent("report", e));
|
|
285
|
+
const config = await this._loadConfigOrReportError(new import_internalReporter.InternalReporter([wireReporter]), overrides);
|
|
286
|
+
if (!config)
|
|
287
|
+
return { status: "failed" };
|
|
288
|
+
const testIdSet = params.testIds ? new Set(params.testIds) : null;
|
|
289
|
+
config.cliListOnly = false;
|
|
290
|
+
config.cliPassWithNoTests = true;
|
|
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.testIdMatcher = testIdSet ? (id) => testIdSet.has(id) : void 0;
|
|
296
|
+
const configReporters = await (0, import_reporters.createReporters)(config, "test", true);
|
|
297
|
+
const reporter = new import_internalReporter.InternalReporter([...configReporters, wireReporter]);
|
|
298
|
+
const stop = new import_utils.ManualPromise();
|
|
299
|
+
const tasks = [
|
|
300
|
+
(0, import_tasks.createApplyRebaselinesTask)(),
|
|
301
|
+
(0, import_tasks.createLoadTask)("out-of-process", { filterOnly: true, failOnLoadErrors: false, doNotRunDepsOutsideProjectFilter: true }),
|
|
302
|
+
...(0, import_tasks.createRunTestsTasks)(config)
|
|
303
|
+
];
|
|
304
|
+
const run = (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), tasks, 0, stop).then(async (status) => {
|
|
305
|
+
this._testRun = void 0;
|
|
306
|
+
return status;
|
|
307
|
+
});
|
|
308
|
+
this._testRun = { run, stop };
|
|
309
|
+
return { status: await run };
|
|
310
|
+
}
|
|
311
|
+
async watch(params) {
|
|
312
|
+
this._watchedTestDependencies = /* @__PURE__ */ new Set();
|
|
313
|
+
for (const fileName of params.fileNames) {
|
|
314
|
+
this._watchedTestDependencies.add(fileName);
|
|
315
|
+
(0, import_compilationCache.dependenciesForTestFile)(fileName).forEach((file) => this._watchedTestDependencies.add(file));
|
|
316
|
+
}
|
|
317
|
+
await this._updateWatcher(true);
|
|
318
|
+
}
|
|
319
|
+
async findRelatedTestFiles(params) {
|
|
320
|
+
const errorReporter = (0, import_reporters.createErrorCollectingReporter)(import_base.internalScreen);
|
|
321
|
+
const reporter = new import_internalReporter.InternalReporter([errorReporter]);
|
|
322
|
+
const config = await this._loadConfigOrReportError(reporter);
|
|
323
|
+
if (!config)
|
|
324
|
+
return { errors: errorReporter.errors(), testFiles: [] };
|
|
325
|
+
const status = await (0, import_tasks.runTasks)(new import_tasks.TestRun(config, reporter), [
|
|
326
|
+
(0, import_tasks.createLoadTask)("out-of-process", { failOnLoadErrors: true, filterOnly: false, populateDependencies: true })
|
|
327
|
+
]);
|
|
328
|
+
if (status !== "passed")
|
|
329
|
+
return { errors: errorReporter.errors(), testFiles: [] };
|
|
330
|
+
return { testFiles: (0, import_compilationCache.affectedTestFiles)(params.files) };
|
|
331
|
+
}
|
|
332
|
+
async stopTests() {
|
|
333
|
+
this._testRun?.stop?.resolve();
|
|
334
|
+
await this._testRun?.run;
|
|
335
|
+
}
|
|
336
|
+
async _setInterceptStdio(intercept) {
|
|
337
|
+
if (process.env.PWTEST_DEBUG)
|
|
338
|
+
return;
|
|
339
|
+
if (intercept) {
|
|
340
|
+
process.stdout.write = (chunk) => {
|
|
341
|
+
this._dispatchEvent("stdio", chunkToPayload("stdout", chunk));
|
|
342
|
+
return true;
|
|
343
|
+
};
|
|
344
|
+
process.stderr.write = (chunk) => {
|
|
345
|
+
this._dispatchEvent("stdio", chunkToPayload("stderr", chunk));
|
|
346
|
+
return true;
|
|
347
|
+
};
|
|
348
|
+
} else {
|
|
349
|
+
process.stdout.write = originalStdoutWrite;
|
|
350
|
+
process.stderr.write = originalStderrWrite;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
async closeGracefully() {
|
|
354
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(0);
|
|
355
|
+
}
|
|
356
|
+
async _loadConfig(overrides) {
|
|
357
|
+
try {
|
|
358
|
+
const config = await (0, import_configLoader.loadConfig)(this._configLocation, overrides);
|
|
359
|
+
if (!this._plugins) {
|
|
360
|
+
(0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
|
|
361
|
+
(0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
|
|
362
|
+
this._plugins = config.plugins || [];
|
|
363
|
+
} else {
|
|
364
|
+
config.plugins.splice(0, config.plugins.length, ...this._plugins);
|
|
365
|
+
}
|
|
366
|
+
return { config };
|
|
367
|
+
} catch (e) {
|
|
368
|
+
return { config: null, error: (0, import_util.serializeError)(e) };
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
async _loadConfigOrReportError(reporter, overrides) {
|
|
372
|
+
const { config, error } = await this._loadConfig(overrides);
|
|
373
|
+
if (config)
|
|
374
|
+
return config;
|
|
375
|
+
reporter.onConfigure(import_teleReceiver.baseFullConfig);
|
|
376
|
+
reporter.onError(error);
|
|
377
|
+
await reporter.onEnd({ status: "failed" });
|
|
378
|
+
await reporter.onExit();
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
async function runUIMode(configFile, configCLIOverrides, options) {
|
|
383
|
+
const configLocation = (0, import_configLoader.resolveConfigLocation)(configFile);
|
|
384
|
+
return await innerRunTestServer(configLocation, configCLIOverrides, options, async (server, cancelPromise) => {
|
|
385
|
+
await (0, import_server.installRootRedirect)(server, [], { ...options, webApp: "uiMode.html" });
|
|
386
|
+
if (options.host !== void 0 || options.port !== void 0) {
|
|
387
|
+
await (0, import_server.openTraceInBrowser)(server.urlPrefix("human-readable"));
|
|
388
|
+
} else {
|
|
389
|
+
const channel = await installedChromiumChannelForUI(configLocation, configCLIOverrides);
|
|
390
|
+
const page = await (0, import_server.openTraceViewerApp)(server.urlPrefix("precise"), "chromium", {
|
|
391
|
+
headless: (0, import_utils.isUnderTest)() && process.env.PWTEST_HEADED_FOR_TEST !== "1",
|
|
392
|
+
persistentContextOptions: {
|
|
393
|
+
handleSIGINT: false,
|
|
394
|
+
channel
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
page.on("close", () => cancelPromise.resolve());
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
async function installedChromiumChannelForUI(configLocation, configCLIOverrides) {
|
|
402
|
+
const config = await (0, import_configLoader.loadConfig)(configLocation, configCLIOverrides).catch((e) => null);
|
|
403
|
+
if (!config)
|
|
404
|
+
return void 0;
|
|
405
|
+
if (config.projects.some((p) => (!p.project.use.browserName || p.project.use.browserName === "chromium") && !p.project.use.channel))
|
|
406
|
+
return void 0;
|
|
407
|
+
for (const channel of ["chromium", "chrome", "msedge"]) {
|
|
408
|
+
if (config.projects.some((p) => p.project.use.channel === channel))
|
|
409
|
+
return channel;
|
|
410
|
+
}
|
|
411
|
+
return void 0;
|
|
412
|
+
}
|
|
413
|
+
async function runTestServer(configFile, configCLIOverrides, options) {
|
|
414
|
+
const configLocation = (0, import_configLoader.resolveConfigLocation)(configFile);
|
|
415
|
+
return await innerRunTestServer(configLocation, configCLIOverrides, options, async (server) => {
|
|
416
|
+
console.log("Listening on " + server.urlPrefix("precise").replace("http:", "ws:") + "/" + server.wsGuid());
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
async function innerRunTestServer(configLocation, configCLIOverrides, options, openUI) {
|
|
420
|
+
if ((0, import_configLoader.restartWithExperimentalTsEsm)(void 0, true))
|
|
421
|
+
return "restarted";
|
|
422
|
+
const testServer = new TestServer(configLocation, configCLIOverrides);
|
|
423
|
+
const cancelPromise = new import_utils.ManualPromise();
|
|
424
|
+
const sigintWatcher = new import_sigIntWatcher.SigIntWatcher();
|
|
425
|
+
process.stdin.on("close", () => (0, import_utils.gracefullyProcessExitDoNotHang)(0));
|
|
426
|
+
void sigintWatcher.promise().then(() => cancelPromise.resolve());
|
|
427
|
+
try {
|
|
428
|
+
const server = await testServer.start(options);
|
|
429
|
+
await openUI(server, cancelPromise);
|
|
430
|
+
await cancelPromise;
|
|
431
|
+
} finally {
|
|
432
|
+
await testServer.stop();
|
|
433
|
+
sigintWatcher.disarm();
|
|
434
|
+
}
|
|
435
|
+
return sigintWatcher.hadSignal() ? "interrupted" : "passed";
|
|
436
|
+
}
|
|
437
|
+
function chunkToPayload(type, chunk) {
|
|
438
|
+
if (chunk instanceof Uint8Array)
|
|
439
|
+
return { type, buffer: chunk.toString("base64") };
|
|
440
|
+
return { type, text: chunk };
|
|
441
|
+
}
|
|
442
|
+
function hasSomeBrowsers() {
|
|
443
|
+
for (const browserName of ["chromium", "webkit", "firefox"]) {
|
|
444
|
+
try {
|
|
445
|
+
import_server.registry.findExecutable(browserName).executablePathOrDie("javascript");
|
|
446
|
+
return true;
|
|
447
|
+
} catch {
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
async function installBrowsers() {
|
|
453
|
+
const executables = import_server.registry.defaultExecutables();
|
|
454
|
+
await import_server.registry.install(executables, false);
|
|
455
|
+
}
|
|
456
|
+
function printInternalError(e) {
|
|
457
|
+
console.error("Internal error:", e);
|
|
458
|
+
}
|
|
459
|
+
async function resolveCtDirs(config) {
|
|
460
|
+
const use = config.config.projects[0].use;
|
|
461
|
+
const relativeTemplateDir = use.ctTemplateDir || "playwright";
|
|
462
|
+
const templateDir = await import_fs.default.promises.realpath(import_path.default.normalize(import_path.default.join(config.configDir, relativeTemplateDir))).catch(() => void 0);
|
|
463
|
+
if (!templateDir)
|
|
464
|
+
return null;
|
|
465
|
+
const outDir = use.ctCacheDir ? import_path.default.resolve(config.configDir, use.ctCacheDir) : import_path.default.resolve(templateDir, ".cache");
|
|
466
|
+
return {
|
|
467
|
+
outDir,
|
|
468
|
+
templateDir
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
472
|
+
0 && (module.exports = {
|
|
473
|
+
TestServerDispatcher,
|
|
474
|
+
resolveCtDirs,
|
|
475
|
+
runTestServer,
|
|
476
|
+
runUIMode
|
|
477
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var uiModeReporter_exports = {};
|
|
20
|
+
__export(uiModeReporter_exports, {
|
|
21
|
+
default: () => uiModeReporter_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(uiModeReporter_exports);
|
|
24
|
+
var import_teleEmitter = require("../reporters/teleEmitter");
|
|
25
|
+
class UIModeReporter extends import_teleEmitter.TeleReporterEmitter {
|
|
26
|
+
constructor(options) {
|
|
27
|
+
super(options._send, { omitBuffers: true });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
var uiModeReporter_default = UIModeReporter;
|
|
@@ -0,0 +1,72 @@
|
|
|
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 vcs_exports = {};
|
|
30
|
+
__export(vcs_exports, {
|
|
31
|
+
detectChangedTestFiles: () => detectChangedTestFiles
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vcs_exports);
|
|
34
|
+
var import_child_process = __toESM(require("child_process"));
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_compilationCache = require("../transform/compilationCache");
|
|
37
|
+
async function detectChangedTestFiles(baseCommit, configDir) {
|
|
38
|
+
function gitFileList(command) {
|
|
39
|
+
try {
|
|
40
|
+
return import_child_process.default.execSync(
|
|
41
|
+
`git ${command}`,
|
|
42
|
+
{ encoding: "utf-8", stdio: "pipe", cwd: configDir }
|
|
43
|
+
).split("\n").filter(Boolean);
|
|
44
|
+
} catch (_error) {
|
|
45
|
+
const error = _error;
|
|
46
|
+
const unknownRevision = error.output.some((line) => line?.includes("unknown revision"));
|
|
47
|
+
if (unknownRevision) {
|
|
48
|
+
const isShallowClone = import_child_process.default.execSync("git rev-parse --is-shallow-repository", { encoding: "utf-8", stdio: "pipe", cwd: configDir }).trim() === "true";
|
|
49
|
+
if (isShallowClone) {
|
|
50
|
+
throw new Error([
|
|
51
|
+
`The repository is a shallow clone and does not have '${baseCommit}' available locally.`,
|
|
52
|
+
`Note that GitHub Actions checkout is shallow by default: https://github.com/actions/checkout`
|
|
53
|
+
].join("\n"));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throw new Error([
|
|
57
|
+
`Cannot detect changed files for --only-changed mode:`,
|
|
58
|
+
`git ${command}`,
|
|
59
|
+
"",
|
|
60
|
+
...error.output
|
|
61
|
+
].join("\n"));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const untrackedFiles = gitFileList(`ls-files --others --exclude-standard`).map((file) => import_path.default.join(configDir, file));
|
|
65
|
+
const [gitRoot] = gitFileList("rev-parse --show-toplevel");
|
|
66
|
+
const trackedFilesWithChanges = gitFileList(`diff ${baseCommit} --name-only`).map((file) => import_path.default.join(gitRoot, file));
|
|
67
|
+
return new Set((0, import_compilationCache.affectedTestFiles)([...untrackedFiles, ...trackedFilesWithChanges]));
|
|
68
|
+
}
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
detectChangedTestFiles
|
|
72
|
+
});
|