@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,137 @@
|
|
|
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 teleSuiteUpdater_exports = {};
|
|
20
|
+
__export(teleSuiteUpdater_exports, {
|
|
21
|
+
TeleSuiteUpdater: () => TeleSuiteUpdater
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(teleSuiteUpdater_exports);
|
|
24
|
+
var import_teleReceiver = require("./teleReceiver");
|
|
25
|
+
var import_testTree = require("./testTree");
|
|
26
|
+
class TeleSuiteUpdater {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.loadErrors = [];
|
|
29
|
+
this.progress = {
|
|
30
|
+
total: 0,
|
|
31
|
+
passed: 0,
|
|
32
|
+
failed: 0,
|
|
33
|
+
skipped: 0
|
|
34
|
+
};
|
|
35
|
+
this._lastRunTestCount = 0;
|
|
36
|
+
this._receiver = new import_teleReceiver.TeleReporterReceiver(this._createReporter(), {
|
|
37
|
+
mergeProjects: true,
|
|
38
|
+
mergeTestCases: true,
|
|
39
|
+
resolvePath: (rootDir, relativePath) => rootDir + options.pathSeparator + relativePath,
|
|
40
|
+
clearPreviousResultsWhenTestBegins: true
|
|
41
|
+
});
|
|
42
|
+
this._options = options;
|
|
43
|
+
}
|
|
44
|
+
_createReporter() {
|
|
45
|
+
return {
|
|
46
|
+
version: () => "v2",
|
|
47
|
+
onConfigure: (c) => {
|
|
48
|
+
this.config = c;
|
|
49
|
+
this._lastRunReceiver = new import_teleReceiver.TeleReporterReceiver({
|
|
50
|
+
version: () => "v2",
|
|
51
|
+
onBegin: (suite) => {
|
|
52
|
+
this._lastRunTestCount = suite.allTests().length;
|
|
53
|
+
this._lastRunReceiver = void 0;
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
mergeProjects: true,
|
|
57
|
+
mergeTestCases: false,
|
|
58
|
+
resolvePath: (rootDir, relativePath) => rootDir + this._options.pathSeparator + relativePath
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
onBegin: (suite) => {
|
|
62
|
+
if (!this.rootSuite)
|
|
63
|
+
this.rootSuite = suite;
|
|
64
|
+
if (this._testResultsSnapshot) {
|
|
65
|
+
for (const test of this.rootSuite.allTests())
|
|
66
|
+
test.results = this._testResultsSnapshot?.get(test.id) || test.results;
|
|
67
|
+
this._testResultsSnapshot = void 0;
|
|
68
|
+
}
|
|
69
|
+
this.progress.total = this._lastRunTestCount;
|
|
70
|
+
this.progress.passed = 0;
|
|
71
|
+
this.progress.failed = 0;
|
|
72
|
+
this.progress.skipped = 0;
|
|
73
|
+
this._options.onUpdate(true);
|
|
74
|
+
},
|
|
75
|
+
onEnd: () => {
|
|
76
|
+
this._options.onUpdate(true);
|
|
77
|
+
},
|
|
78
|
+
onTestBegin: (test, testResult) => {
|
|
79
|
+
testResult[import_testTree.statusEx] = "running";
|
|
80
|
+
this._options.onUpdate();
|
|
81
|
+
},
|
|
82
|
+
onTestEnd: (test, testResult) => {
|
|
83
|
+
if (test.outcome() === "skipped")
|
|
84
|
+
++this.progress.skipped;
|
|
85
|
+
else if (test.outcome() === "unexpected")
|
|
86
|
+
++this.progress.failed;
|
|
87
|
+
else
|
|
88
|
+
++this.progress.passed;
|
|
89
|
+
testResult[import_testTree.statusEx] = testResult.status;
|
|
90
|
+
this._options.onUpdate();
|
|
91
|
+
},
|
|
92
|
+
onError: (error) => this._handleOnError(error),
|
|
93
|
+
printsToStdio: () => false
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
processGlobalReport(report) {
|
|
97
|
+
const receiver = new import_teleReceiver.TeleReporterReceiver({
|
|
98
|
+
version: () => "v2",
|
|
99
|
+
onConfigure: (c) => {
|
|
100
|
+
this.config = c;
|
|
101
|
+
},
|
|
102
|
+
onError: (error) => this._handleOnError(error)
|
|
103
|
+
});
|
|
104
|
+
for (const message of report)
|
|
105
|
+
void receiver.dispatch(message);
|
|
106
|
+
}
|
|
107
|
+
processListReport(report) {
|
|
108
|
+
const tests = this.rootSuite?.allTests() || [];
|
|
109
|
+
this._testResultsSnapshot = new Map(tests.map((test) => [test.id, test.results]));
|
|
110
|
+
this._receiver.reset();
|
|
111
|
+
for (const message of report)
|
|
112
|
+
void this._receiver.dispatch(message);
|
|
113
|
+
}
|
|
114
|
+
processTestReportEvent(message) {
|
|
115
|
+
this._lastRunReceiver?.dispatch(message)?.catch(() => {
|
|
116
|
+
});
|
|
117
|
+
this._receiver.dispatch(message)?.catch(() => {
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
_handleOnError(error) {
|
|
121
|
+
this.loadErrors.push(error);
|
|
122
|
+
this._options.onError?.(error);
|
|
123
|
+
this._options.onUpdate();
|
|
124
|
+
}
|
|
125
|
+
asModel() {
|
|
126
|
+
return {
|
|
127
|
+
rootSuite: this.rootSuite || new import_teleReceiver.TeleSuite("", "root"),
|
|
128
|
+
config: this.config,
|
|
129
|
+
loadErrors: this.loadErrors,
|
|
130
|
+
progress: this.progress
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
TeleSuiteUpdater
|
|
137
|
+
});
|
|
@@ -0,0 +1,211 @@
|
|
|
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 testServerConnection_exports = {};
|
|
30
|
+
__export(testServerConnection_exports, {
|
|
31
|
+
TestServerConnection: () => TestServerConnection,
|
|
32
|
+
WebSocketTestServerTransport: () => WebSocketTestServerTransport
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(testServerConnection_exports);
|
|
35
|
+
var events = __toESM(require("./events"));
|
|
36
|
+
class WebSocketTestServerTransport {
|
|
37
|
+
constructor(url) {
|
|
38
|
+
this._ws = new WebSocket(url);
|
|
39
|
+
}
|
|
40
|
+
onmessage(listener) {
|
|
41
|
+
this._ws.addEventListener("message", (event) => listener(event.data.toString()));
|
|
42
|
+
}
|
|
43
|
+
onopen(listener) {
|
|
44
|
+
this._ws.addEventListener("open", listener);
|
|
45
|
+
}
|
|
46
|
+
onerror(listener) {
|
|
47
|
+
this._ws.addEventListener("error", listener);
|
|
48
|
+
}
|
|
49
|
+
onclose(listener) {
|
|
50
|
+
this._ws.addEventListener("close", listener);
|
|
51
|
+
}
|
|
52
|
+
send(data) {
|
|
53
|
+
this._ws.send(data);
|
|
54
|
+
}
|
|
55
|
+
close() {
|
|
56
|
+
this._ws.close();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
class TestServerConnection {
|
|
60
|
+
constructor(transport) {
|
|
61
|
+
this._onCloseEmitter = new events.EventEmitter();
|
|
62
|
+
this._onReportEmitter = new events.EventEmitter();
|
|
63
|
+
this._onStdioEmitter = new events.EventEmitter();
|
|
64
|
+
this._onTestFilesChangedEmitter = new events.EventEmitter();
|
|
65
|
+
this._onLoadTraceRequestedEmitter = new events.EventEmitter();
|
|
66
|
+
this._lastId = 0;
|
|
67
|
+
this._callbacks = /* @__PURE__ */ new Map();
|
|
68
|
+
this._isClosed = false;
|
|
69
|
+
this.onClose = this._onCloseEmitter.event;
|
|
70
|
+
this.onReport = this._onReportEmitter.event;
|
|
71
|
+
this.onStdio = this._onStdioEmitter.event;
|
|
72
|
+
this.onTestFilesChanged = this._onTestFilesChangedEmitter.event;
|
|
73
|
+
this.onLoadTraceRequested = this._onLoadTraceRequestedEmitter.event;
|
|
74
|
+
this._transport = transport;
|
|
75
|
+
this._transport.onmessage((data) => {
|
|
76
|
+
const message = JSON.parse(data);
|
|
77
|
+
const { id, result, error, method, params } = message;
|
|
78
|
+
if (id) {
|
|
79
|
+
const callback = this._callbacks.get(id);
|
|
80
|
+
if (!callback)
|
|
81
|
+
return;
|
|
82
|
+
this._callbacks.delete(id);
|
|
83
|
+
if (error)
|
|
84
|
+
callback.reject(new Error(error));
|
|
85
|
+
else
|
|
86
|
+
callback.resolve(result);
|
|
87
|
+
} else {
|
|
88
|
+
this._dispatchEvent(method, params);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const pingInterval = setInterval(() => this._sendMessage("ping").catch(() => {
|
|
92
|
+
}), 3e4);
|
|
93
|
+
this._connectedPromise = new Promise((f, r) => {
|
|
94
|
+
this._transport.onopen(f);
|
|
95
|
+
this._transport.onerror(r);
|
|
96
|
+
});
|
|
97
|
+
this._transport.onclose(() => {
|
|
98
|
+
this._isClosed = true;
|
|
99
|
+
this._onCloseEmitter.fire();
|
|
100
|
+
clearInterval(pingInterval);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
isClosed() {
|
|
104
|
+
return this._isClosed;
|
|
105
|
+
}
|
|
106
|
+
async _sendMessage(method, params) {
|
|
107
|
+
const logForTest = globalThis.__logForTest;
|
|
108
|
+
logForTest?.({ method, params });
|
|
109
|
+
await this._connectedPromise;
|
|
110
|
+
const id = ++this._lastId;
|
|
111
|
+
const message = { id, method, params };
|
|
112
|
+
this._transport.send(JSON.stringify(message));
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
this._callbacks.set(id, { resolve, reject });
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
_sendMessageNoReply(method, params) {
|
|
118
|
+
this._sendMessage(method, params).catch(() => {
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
_dispatchEvent(method, params) {
|
|
122
|
+
if (method === "report")
|
|
123
|
+
this._onReportEmitter.fire(params);
|
|
124
|
+
else if (method === "stdio")
|
|
125
|
+
this._onStdioEmitter.fire(params);
|
|
126
|
+
else if (method === "testFilesChanged")
|
|
127
|
+
this._onTestFilesChangedEmitter.fire(params);
|
|
128
|
+
else if (method === "loadTraceRequested")
|
|
129
|
+
this._onLoadTraceRequestedEmitter.fire(params);
|
|
130
|
+
}
|
|
131
|
+
async initialize(params) {
|
|
132
|
+
await this._sendMessage("initialize", params);
|
|
133
|
+
}
|
|
134
|
+
async ping(params) {
|
|
135
|
+
await this._sendMessage("ping", params);
|
|
136
|
+
}
|
|
137
|
+
async pingNoReply(params) {
|
|
138
|
+
this._sendMessageNoReply("ping", params);
|
|
139
|
+
}
|
|
140
|
+
async watch(params) {
|
|
141
|
+
await this._sendMessage("watch", params);
|
|
142
|
+
}
|
|
143
|
+
watchNoReply(params) {
|
|
144
|
+
this._sendMessageNoReply("watch", params);
|
|
145
|
+
}
|
|
146
|
+
async open(params) {
|
|
147
|
+
await this._sendMessage("open", params);
|
|
148
|
+
}
|
|
149
|
+
openNoReply(params) {
|
|
150
|
+
this._sendMessageNoReply("open", params);
|
|
151
|
+
}
|
|
152
|
+
async resizeTerminal(params) {
|
|
153
|
+
await this._sendMessage("resizeTerminal", params);
|
|
154
|
+
}
|
|
155
|
+
resizeTerminalNoReply(params) {
|
|
156
|
+
this._sendMessageNoReply("resizeTerminal", params);
|
|
157
|
+
}
|
|
158
|
+
async checkBrowsers(params) {
|
|
159
|
+
return await this._sendMessage("checkBrowsers", params);
|
|
160
|
+
}
|
|
161
|
+
async installBrowsers(params) {
|
|
162
|
+
await this._sendMessage("installBrowsers", params);
|
|
163
|
+
}
|
|
164
|
+
async runGlobalSetup(params) {
|
|
165
|
+
return await this._sendMessage("runGlobalSetup", params);
|
|
166
|
+
}
|
|
167
|
+
async runGlobalTeardown(params) {
|
|
168
|
+
return await this._sendMessage("runGlobalTeardown", params);
|
|
169
|
+
}
|
|
170
|
+
async startDevServer(params) {
|
|
171
|
+
return await this._sendMessage("startDevServer", params);
|
|
172
|
+
}
|
|
173
|
+
async stopDevServer(params) {
|
|
174
|
+
return await this._sendMessage("stopDevServer", params);
|
|
175
|
+
}
|
|
176
|
+
async clearCache(params) {
|
|
177
|
+
return await this._sendMessage("clearCache", params);
|
|
178
|
+
}
|
|
179
|
+
async listFiles(params) {
|
|
180
|
+
return await this._sendMessage("listFiles", params);
|
|
181
|
+
}
|
|
182
|
+
async listTests(params) {
|
|
183
|
+
return await this._sendMessage("listTests", params);
|
|
184
|
+
}
|
|
185
|
+
async runTests(params) {
|
|
186
|
+
return await this._sendMessage("runTests", params);
|
|
187
|
+
}
|
|
188
|
+
async findRelatedTestFiles(params) {
|
|
189
|
+
return await this._sendMessage("findRelatedTestFiles", params);
|
|
190
|
+
}
|
|
191
|
+
async stopTests(params) {
|
|
192
|
+
await this._sendMessage("stopTests", params);
|
|
193
|
+
}
|
|
194
|
+
stopTestsNoReply(params) {
|
|
195
|
+
this._sendMessageNoReply("stopTests", params);
|
|
196
|
+
}
|
|
197
|
+
async closeGracefully(params) {
|
|
198
|
+
await this._sendMessage("closeGracefully", params);
|
|
199
|
+
}
|
|
200
|
+
close() {
|
|
201
|
+
try {
|
|
202
|
+
this._transport.close();
|
|
203
|
+
} catch {
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
208
|
+
0 && (module.exports = {
|
|
209
|
+
TestServerConnection,
|
|
210
|
+
WebSocketTestServerTransport
|
|
211
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var testServerInterface_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(testServerInterface_exports);
|
|
@@ -0,0 +1,307 @@
|
|
|
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 testTree_exports = {};
|
|
20
|
+
__export(testTree_exports, {
|
|
21
|
+
TestTree: () => TestTree,
|
|
22
|
+
collectTestIds: () => collectTestIds,
|
|
23
|
+
sortAndPropagateStatus: () => sortAndPropagateStatus,
|
|
24
|
+
statusEx: () => statusEx
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(testTree_exports);
|
|
27
|
+
class TestTree {
|
|
28
|
+
constructor(rootFolder, rootSuite, loadErrors, projectFilters, pathSeparator) {
|
|
29
|
+
this._treeItemById = /* @__PURE__ */ new Map();
|
|
30
|
+
this._treeItemByTestId = /* @__PURE__ */ new Map();
|
|
31
|
+
const filterProjects = projectFilters && [...projectFilters.values()].some(Boolean);
|
|
32
|
+
this.pathSeparator = pathSeparator;
|
|
33
|
+
this.rootItem = {
|
|
34
|
+
kind: "group",
|
|
35
|
+
subKind: "folder",
|
|
36
|
+
id: rootFolder,
|
|
37
|
+
title: "",
|
|
38
|
+
location: { file: "", line: 0, column: 0 },
|
|
39
|
+
duration: 0,
|
|
40
|
+
parent: void 0,
|
|
41
|
+
children: [],
|
|
42
|
+
status: "none",
|
|
43
|
+
hasLoadErrors: false
|
|
44
|
+
};
|
|
45
|
+
this._treeItemById.set(rootFolder, this.rootItem);
|
|
46
|
+
const visitSuite = (project, parentSuite, parentGroup) => {
|
|
47
|
+
for (const suite of parentSuite.suites) {
|
|
48
|
+
if (!suite.title) {
|
|
49
|
+
visitSuite(project, suite, parentGroup);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
let group = parentGroup.children.find((item) => item.kind === "group" && item.title === suite.title);
|
|
53
|
+
if (!group) {
|
|
54
|
+
group = {
|
|
55
|
+
kind: "group",
|
|
56
|
+
subKind: "describe",
|
|
57
|
+
id: "suite:" + parentSuite.titlePath().join("") + "" + suite.title,
|
|
58
|
+
// account for anonymous suites
|
|
59
|
+
title: suite.title,
|
|
60
|
+
location: suite.location,
|
|
61
|
+
duration: 0,
|
|
62
|
+
parent: parentGroup,
|
|
63
|
+
children: [],
|
|
64
|
+
status: "none",
|
|
65
|
+
hasLoadErrors: false
|
|
66
|
+
};
|
|
67
|
+
this._addChild(parentGroup, group);
|
|
68
|
+
}
|
|
69
|
+
visitSuite(project, suite, group);
|
|
70
|
+
}
|
|
71
|
+
for (const test of parentSuite.tests) {
|
|
72
|
+
const title = test.title;
|
|
73
|
+
let testCaseItem = parentGroup.children.find((t) => t.kind !== "group" && t.title === title);
|
|
74
|
+
if (!testCaseItem) {
|
|
75
|
+
testCaseItem = {
|
|
76
|
+
kind: "case",
|
|
77
|
+
id: "test:" + test.titlePath().join(""),
|
|
78
|
+
title,
|
|
79
|
+
parent: parentGroup,
|
|
80
|
+
children: [],
|
|
81
|
+
tests: [],
|
|
82
|
+
location: test.location,
|
|
83
|
+
duration: 0,
|
|
84
|
+
status: "none",
|
|
85
|
+
project: void 0,
|
|
86
|
+
test: void 0,
|
|
87
|
+
tags: test.tags
|
|
88
|
+
};
|
|
89
|
+
this._addChild(parentGroup, testCaseItem);
|
|
90
|
+
}
|
|
91
|
+
const result = test.results[0];
|
|
92
|
+
let status = "none";
|
|
93
|
+
if (result?.[statusEx] === "scheduled")
|
|
94
|
+
status = "scheduled";
|
|
95
|
+
else if (result?.[statusEx] === "running")
|
|
96
|
+
status = "running";
|
|
97
|
+
else if (result?.status === "skipped")
|
|
98
|
+
status = "skipped";
|
|
99
|
+
else if (result?.status === "interrupted")
|
|
100
|
+
status = "none";
|
|
101
|
+
else if (result && test.outcome() !== "expected")
|
|
102
|
+
status = "failed";
|
|
103
|
+
else if (result && test.outcome() === "expected")
|
|
104
|
+
status = "passed";
|
|
105
|
+
testCaseItem.tests.push(test);
|
|
106
|
+
const testItem = {
|
|
107
|
+
kind: "test",
|
|
108
|
+
id: test.id,
|
|
109
|
+
title: project.name,
|
|
110
|
+
location: test.location,
|
|
111
|
+
test,
|
|
112
|
+
parent: testCaseItem,
|
|
113
|
+
children: [],
|
|
114
|
+
status,
|
|
115
|
+
duration: test.results.length ? Math.max(0, test.results[0].duration) : 0,
|
|
116
|
+
project
|
|
117
|
+
};
|
|
118
|
+
this._addChild(testCaseItem, testItem);
|
|
119
|
+
this._treeItemByTestId.set(test.id, testItem);
|
|
120
|
+
testCaseItem.duration = testCaseItem.children.reduce((a, b) => a + b.duration, 0);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
for (const projectSuite of rootSuite?.suites || []) {
|
|
124
|
+
if (filterProjects && !projectFilters.get(projectSuite.title))
|
|
125
|
+
continue;
|
|
126
|
+
for (const fileSuite of projectSuite.suites) {
|
|
127
|
+
const fileItem = this._fileItem(fileSuite.location.file.split(pathSeparator), true);
|
|
128
|
+
visitSuite(projectSuite.project(), fileSuite, fileItem);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
for (const loadError of loadErrors) {
|
|
132
|
+
if (!loadError.location)
|
|
133
|
+
continue;
|
|
134
|
+
const fileItem = this._fileItem(loadError.location.file.split(pathSeparator), true);
|
|
135
|
+
fileItem.hasLoadErrors = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
_addChild(parent, child) {
|
|
139
|
+
parent.children.push(child);
|
|
140
|
+
child.parent = parent;
|
|
141
|
+
this._treeItemById.set(child.id, child);
|
|
142
|
+
}
|
|
143
|
+
filterTree(filterText, statusFilters, runningTestIds) {
|
|
144
|
+
const tokens = filterText.trim().toLowerCase().split(" ");
|
|
145
|
+
const filtersStatuses = [...statusFilters.values()].some(Boolean);
|
|
146
|
+
const filter = (testCase) => {
|
|
147
|
+
const titleWithTags = [...testCase.tests[0].titlePath(), ...testCase.tests[0].tags].join(" ").toLowerCase();
|
|
148
|
+
if (!tokens.every((token) => titleWithTags.includes(token)) && !testCase.tests.some((t) => runningTestIds?.has(t.id)))
|
|
149
|
+
return false;
|
|
150
|
+
testCase.children = testCase.children.filter((test) => {
|
|
151
|
+
return !filtersStatuses || runningTestIds?.has(test.test.id) || statusFilters.get(test.status);
|
|
152
|
+
});
|
|
153
|
+
testCase.tests = testCase.children.map((c) => c.test);
|
|
154
|
+
return !!testCase.children.length;
|
|
155
|
+
};
|
|
156
|
+
const visit = (treeItem) => {
|
|
157
|
+
const newChildren = [];
|
|
158
|
+
for (const child of treeItem.children) {
|
|
159
|
+
if (child.kind === "case") {
|
|
160
|
+
if (filter(child))
|
|
161
|
+
newChildren.push(child);
|
|
162
|
+
} else {
|
|
163
|
+
visit(child);
|
|
164
|
+
if (child.children.length || child.hasLoadErrors)
|
|
165
|
+
newChildren.push(child);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
treeItem.children = newChildren;
|
|
169
|
+
};
|
|
170
|
+
visit(this.rootItem);
|
|
171
|
+
}
|
|
172
|
+
_fileItem(filePath, isFile) {
|
|
173
|
+
if (filePath.length === 0)
|
|
174
|
+
return this.rootItem;
|
|
175
|
+
const fileName = filePath.join(this.pathSeparator);
|
|
176
|
+
const existingFileItem = this._treeItemById.get(fileName);
|
|
177
|
+
if (existingFileItem)
|
|
178
|
+
return existingFileItem;
|
|
179
|
+
const parentFileItem = this._fileItem(filePath.slice(0, filePath.length - 1), false);
|
|
180
|
+
const fileItem = {
|
|
181
|
+
kind: "group",
|
|
182
|
+
subKind: isFile ? "file" : "folder",
|
|
183
|
+
id: fileName,
|
|
184
|
+
title: filePath[filePath.length - 1],
|
|
185
|
+
location: { file: fileName, line: 0, column: 0 },
|
|
186
|
+
duration: 0,
|
|
187
|
+
parent: parentFileItem,
|
|
188
|
+
children: [],
|
|
189
|
+
status: "none",
|
|
190
|
+
hasLoadErrors: false
|
|
191
|
+
};
|
|
192
|
+
this._addChild(parentFileItem, fileItem);
|
|
193
|
+
return fileItem;
|
|
194
|
+
}
|
|
195
|
+
sortAndPropagateStatus() {
|
|
196
|
+
sortAndPropagateStatus(this.rootItem);
|
|
197
|
+
}
|
|
198
|
+
flattenForSingleProject() {
|
|
199
|
+
const visit = (treeItem) => {
|
|
200
|
+
if (treeItem.kind === "case" && treeItem.children.length === 1) {
|
|
201
|
+
treeItem.project = treeItem.children[0].project;
|
|
202
|
+
treeItem.test = treeItem.children[0].test;
|
|
203
|
+
treeItem.children = [];
|
|
204
|
+
this._treeItemByTestId.set(treeItem.test.id, treeItem);
|
|
205
|
+
} else {
|
|
206
|
+
treeItem.children.forEach(visit);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
visit(this.rootItem);
|
|
210
|
+
}
|
|
211
|
+
shortenRoot() {
|
|
212
|
+
let shortRoot = this.rootItem;
|
|
213
|
+
while (shortRoot.children.length === 1 && shortRoot.children[0].kind === "group" && shortRoot.children[0].subKind === "folder")
|
|
214
|
+
shortRoot = shortRoot.children[0];
|
|
215
|
+
shortRoot.location = this.rootItem.location;
|
|
216
|
+
this.rootItem = shortRoot;
|
|
217
|
+
}
|
|
218
|
+
testIds() {
|
|
219
|
+
const result = /* @__PURE__ */ new Set();
|
|
220
|
+
const visit = (treeItem) => {
|
|
221
|
+
if (treeItem.kind === "case")
|
|
222
|
+
treeItem.tests.forEach((t) => result.add(t.id));
|
|
223
|
+
treeItem.children.forEach(visit);
|
|
224
|
+
};
|
|
225
|
+
visit(this.rootItem);
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
fileNames() {
|
|
229
|
+
const result = /* @__PURE__ */ new Set();
|
|
230
|
+
const visit = (treeItem) => {
|
|
231
|
+
if (treeItem.kind === "group" && treeItem.subKind === "file")
|
|
232
|
+
result.add(treeItem.id);
|
|
233
|
+
else
|
|
234
|
+
treeItem.children.forEach(visit);
|
|
235
|
+
};
|
|
236
|
+
visit(this.rootItem);
|
|
237
|
+
return [...result];
|
|
238
|
+
}
|
|
239
|
+
flatTreeItems() {
|
|
240
|
+
const result = [];
|
|
241
|
+
const visit = (treeItem) => {
|
|
242
|
+
result.push(treeItem);
|
|
243
|
+
treeItem.children.forEach(visit);
|
|
244
|
+
};
|
|
245
|
+
visit(this.rootItem);
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
248
|
+
treeItemById(id) {
|
|
249
|
+
return this._treeItemById.get(id);
|
|
250
|
+
}
|
|
251
|
+
collectTestIds(treeItem) {
|
|
252
|
+
return treeItem ? collectTestIds(treeItem) : /* @__PURE__ */ new Set();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function sortAndPropagateStatus(treeItem) {
|
|
256
|
+
for (const child of treeItem.children)
|
|
257
|
+
sortAndPropagateStatus(child);
|
|
258
|
+
if (treeItem.kind === "group") {
|
|
259
|
+
treeItem.children.sort((a, b) => {
|
|
260
|
+
const fc = a.location.file.localeCompare(b.location.file);
|
|
261
|
+
return fc || a.location.line - b.location.line;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
let allPassed = treeItem.children.length > 0;
|
|
265
|
+
let allSkipped = treeItem.children.length > 0;
|
|
266
|
+
let hasFailed = false;
|
|
267
|
+
let hasRunning = false;
|
|
268
|
+
let hasScheduled = false;
|
|
269
|
+
for (const child of treeItem.children) {
|
|
270
|
+
allSkipped = allSkipped && child.status === "skipped";
|
|
271
|
+
allPassed = allPassed && (child.status === "passed" || child.status === "skipped");
|
|
272
|
+
hasFailed = hasFailed || child.status === "failed";
|
|
273
|
+
hasRunning = hasRunning || child.status === "running";
|
|
274
|
+
hasScheduled = hasScheduled || child.status === "scheduled";
|
|
275
|
+
}
|
|
276
|
+
if (hasRunning)
|
|
277
|
+
treeItem.status = "running";
|
|
278
|
+
else if (hasScheduled)
|
|
279
|
+
treeItem.status = "scheduled";
|
|
280
|
+
else if (hasFailed)
|
|
281
|
+
treeItem.status = "failed";
|
|
282
|
+
else if (allSkipped)
|
|
283
|
+
treeItem.status = "skipped";
|
|
284
|
+
else if (allPassed)
|
|
285
|
+
treeItem.status = "passed";
|
|
286
|
+
}
|
|
287
|
+
function collectTestIds(treeItem) {
|
|
288
|
+
const testIds = /* @__PURE__ */ new Set();
|
|
289
|
+
const visit = (treeItem2) => {
|
|
290
|
+
if (treeItem2.kind === "case")
|
|
291
|
+
treeItem2.tests.map((t) => t.id).forEach((id) => testIds.add(id));
|
|
292
|
+
else if (treeItem2.kind === "test")
|
|
293
|
+
testIds.add(treeItem2.id);
|
|
294
|
+
else
|
|
295
|
+
treeItem2.children?.forEach(visit);
|
|
296
|
+
};
|
|
297
|
+
visit(treeItem);
|
|
298
|
+
return testIds;
|
|
299
|
+
}
|
|
300
|
+
const statusEx = Symbol("statusEx");
|
|
301
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
302
|
+
0 && (module.exports = {
|
|
303
|
+
TestTree,
|
|
304
|
+
collectTestIds,
|
|
305
|
+
sortAndPropagateStatus,
|
|
306
|
+
statusEx
|
|
307
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_d_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_d_exports);
|