@ohos-ports/playwright 1.54.2-beta.1

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.
Files changed (109) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +168 -0
  4. package/ThirdPartyNotices.txt +3984 -0
  5. package/cli.js +19 -0
  6. package/index.d.ts +17 -0
  7. package/index.js +17 -0
  8. package/index.mjs +18 -0
  9. package/jsx-runtime.js +42 -0
  10. package/jsx-runtime.mjs +21 -0
  11. package/lib/common/config.js +272 -0
  12. package/lib/common/configLoader.js +343 -0
  13. package/lib/common/esmLoaderHost.js +102 -0
  14. package/lib/common/expectBundle.js +49 -0
  15. package/lib/common/expectBundleImpl.js +389 -0
  16. package/lib/common/fixtures.js +302 -0
  17. package/lib/common/globals.js +58 -0
  18. package/lib/common/ipc.js +60 -0
  19. package/lib/common/poolBuilder.js +85 -0
  20. package/lib/common/process.js +104 -0
  21. package/lib/common/suiteUtils.js +149 -0
  22. package/lib/common/test.js +321 -0
  23. package/lib/common/testLoader.js +100 -0
  24. package/lib/common/testType.js +307 -0
  25. package/lib/fsWatcher.js +67 -0
  26. package/lib/index.js +670 -0
  27. package/lib/internalsForTest.js +42 -0
  28. package/lib/isomorphic/events.js +77 -0
  29. package/lib/isomorphic/folders.js +30 -0
  30. package/lib/isomorphic/stringInternPool.js +69 -0
  31. package/lib/isomorphic/teleReceiver.js +507 -0
  32. package/lib/isomorphic/teleSuiteUpdater.js +137 -0
  33. package/lib/isomorphic/testServerConnection.js +211 -0
  34. package/lib/isomorphic/testServerInterface.js +16 -0
  35. package/lib/isomorphic/testTree.js +307 -0
  36. package/lib/isomorphic/types.d.js +16 -0
  37. package/lib/loader/loaderMain.js +59 -0
  38. package/lib/matchers/expect.js +326 -0
  39. package/lib/matchers/matcherHint.js +59 -0
  40. package/lib/matchers/matchers.js +360 -0
  41. package/lib/matchers/toBeTruthy.js +71 -0
  42. package/lib/matchers/toEqual.js +94 -0
  43. package/lib/matchers/toHaveURL.js +117 -0
  44. package/lib/matchers/toMatchAriaSnapshot.js +164 -0
  45. package/lib/matchers/toMatchSnapshot.js +338 -0
  46. package/lib/matchers/toMatchText.js +105 -0
  47. package/lib/plugins/gitCommitInfoPlugin.js +198 -0
  48. package/lib/plugins/index.js +28 -0
  49. package/lib/plugins/webServerPlugin.js +207 -0
  50. package/lib/program.js +392 -0
  51. package/lib/reporters/base.js +604 -0
  52. package/lib/reporters/blob.js +135 -0
  53. package/lib/reporters/dot.js +82 -0
  54. package/lib/reporters/empty.js +32 -0
  55. package/lib/reporters/github.js +127 -0
  56. package/lib/reporters/html.js +627 -0
  57. package/lib/reporters/internalReporter.js +129 -0
  58. package/lib/reporters/json.js +254 -0
  59. package/lib/reporters/junit.js +230 -0
  60. package/lib/reporters/line.js +113 -0
  61. package/lib/reporters/list.js +230 -0
  62. package/lib/reporters/markdown.js +144 -0
  63. package/lib/reporters/merge.js +533 -0
  64. package/lib/reporters/multiplexer.js +104 -0
  65. package/lib/reporters/reporterV2.js +102 -0
  66. package/lib/reporters/teleEmitter.js +295 -0
  67. package/lib/reporters/versions/blobV1.js +16 -0
  68. package/lib/runner/dispatcher.js +484 -0
  69. package/lib/runner/failureTracker.js +62 -0
  70. package/lib/runner/lastRun.js +74 -0
  71. package/lib/runner/loadUtils.js +299 -0
  72. package/lib/runner/loaderHost.js +89 -0
  73. package/lib/runner/processHost.js +161 -0
  74. package/lib/runner/projectUtils.js +235 -0
  75. package/lib/runner/rebase.js +189 -0
  76. package/lib/runner/reporters.js +162 -0
  77. package/lib/runner/runner.js +110 -0
  78. package/lib/runner/sigIntWatcher.js +96 -0
  79. package/lib/runner/taskRunner.js +127 -0
  80. package/lib/runner/tasks.js +400 -0
  81. package/lib/runner/testGroups.js +117 -0
  82. package/lib/runner/testServer.js +483 -0
  83. package/lib/runner/uiModeReporter.js +30 -0
  84. package/lib/runner/vcs.js +72 -0
  85. package/lib/runner/watchMode.js +391 -0
  86. package/lib/runner/workerHost.js +93 -0
  87. package/lib/third_party/pirates.js +62 -0
  88. package/lib/third_party/tsconfig-loader.js +103 -0
  89. package/lib/transform/babelBundle.js +43 -0
  90. package/lib/transform/babelBundleImpl.js +477 -0
  91. package/lib/transform/compilationCache.js +255 -0
  92. package/lib/transform/esmLoader.js +104 -0
  93. package/lib/transform/portTransport.js +67 -0
  94. package/lib/transform/transform.js +293 -0
  95. package/lib/util.js +426 -0
  96. package/lib/utilsBundle.js +43 -0
  97. package/lib/utilsBundleImpl.js +100 -0
  98. package/lib/worker/fixtureRunner.js +253 -0
  99. package/lib/worker/testInfo.js +474 -0
  100. package/lib/worker/testTracing.js +343 -0
  101. package/lib/worker/timeoutManager.js +174 -0
  102. package/lib/worker/util.js +31 -0
  103. package/lib/worker/workerMain.js +511 -0
  104. package/package.json +64 -0
  105. package/test.d.ts +18 -0
  106. package/test.js +24 -0
  107. package/test.mjs +33 -0
  108. package/types/test.d.ts +10141 -0
  109. package/types/testReporter.d.ts +816 -0
@@ -0,0 +1,507 @@
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 teleReceiver_exports = {};
20
+ __export(teleReceiver_exports, {
21
+ TeleReporterReceiver: () => TeleReporterReceiver,
22
+ TeleSuite: () => TeleSuite,
23
+ TeleTestCase: () => TeleTestCase,
24
+ TeleTestResult: () => TeleTestResult,
25
+ baseFullConfig: () => baseFullConfig,
26
+ computeTestCaseOutcome: () => computeTestCaseOutcome,
27
+ parseRegexPatterns: () => parseRegexPatterns,
28
+ serializeRegexPatterns: () => serializeRegexPatterns
29
+ });
30
+ module.exports = __toCommonJS(teleReceiver_exports);
31
+ class TeleReporterReceiver {
32
+ constructor(reporter, options = {}) {
33
+ this.isListing = false;
34
+ this._tests = /* @__PURE__ */ new Map();
35
+ this._rootSuite = new TeleSuite("", "root");
36
+ this._options = options;
37
+ this._reporter = reporter;
38
+ }
39
+ reset() {
40
+ this._rootSuite._entries = [];
41
+ this._tests.clear();
42
+ }
43
+ dispatch(message) {
44
+ const { method, params } = message;
45
+ if (method === "onConfigure") {
46
+ this._onConfigure(params.config);
47
+ return;
48
+ }
49
+ if (method === "onProject") {
50
+ this._onProject(params.project);
51
+ return;
52
+ }
53
+ if (method === "onBegin") {
54
+ this._onBegin();
55
+ return;
56
+ }
57
+ if (method === "onTestBegin") {
58
+ this._onTestBegin(params.testId, params.result);
59
+ return;
60
+ }
61
+ if (method === "onTestEnd") {
62
+ this._onTestEnd(params.test, params.result);
63
+ return;
64
+ }
65
+ if (method === "onStepBegin") {
66
+ this._onStepBegin(params.testId, params.resultId, params.step);
67
+ return;
68
+ }
69
+ if (method === "onAttach") {
70
+ this._onAttach(params.testId, params.resultId, params.attachments);
71
+ return;
72
+ }
73
+ if (method === "onStepEnd") {
74
+ this._onStepEnd(params.testId, params.resultId, params.step);
75
+ return;
76
+ }
77
+ if (method === "onError") {
78
+ this._onError(params.error);
79
+ return;
80
+ }
81
+ if (method === "onStdIO") {
82
+ this._onStdIO(params.type, params.testId, params.resultId, params.data, params.isBase64);
83
+ return;
84
+ }
85
+ if (method === "onEnd")
86
+ return this._onEnd(params.result);
87
+ if (method === "onExit")
88
+ return this._onExit();
89
+ }
90
+ _onConfigure(config) {
91
+ this._rootDir = config.rootDir;
92
+ this._config = this._parseConfig(config);
93
+ this._reporter.onConfigure?.(this._config);
94
+ }
95
+ _onProject(project) {
96
+ let projectSuite = this._options.mergeProjects ? this._rootSuite.suites.find((suite) => suite.project().name === project.name) : void 0;
97
+ if (!projectSuite) {
98
+ projectSuite = new TeleSuite(project.name, "project");
99
+ this._rootSuite._addSuite(projectSuite);
100
+ }
101
+ projectSuite._project = this._parseProject(project);
102
+ for (const suite of project.suites)
103
+ this._mergeSuiteInto(suite, projectSuite);
104
+ }
105
+ _onBegin() {
106
+ this._reporter.onBegin?.(this._rootSuite);
107
+ }
108
+ _onTestBegin(testId, payload) {
109
+ const test = this._tests.get(testId);
110
+ if (this._options.clearPreviousResultsWhenTestBegins)
111
+ test.results = [];
112
+ const testResult = test._createTestResult(payload.id);
113
+ testResult.retry = payload.retry;
114
+ testResult.workerIndex = payload.workerIndex;
115
+ testResult.parallelIndex = payload.parallelIndex;
116
+ testResult.setStartTimeNumber(payload.startTime);
117
+ this._reporter.onTestBegin?.(test, testResult);
118
+ }
119
+ _onTestEnd(testEndPayload, payload) {
120
+ const test = this._tests.get(testEndPayload.testId);
121
+ test.timeout = testEndPayload.timeout;
122
+ test.expectedStatus = testEndPayload.expectedStatus;
123
+ const result = test.results.find((r) => r._id === payload.id);
124
+ result.duration = payload.duration;
125
+ result.status = payload.status;
126
+ result.errors = payload.errors;
127
+ result.error = result.errors?.[0];
128
+ if (!!payload.attachments)
129
+ result.attachments = this._parseAttachments(payload.attachments);
130
+ if (payload.annotations) {
131
+ this._absoluteAnnotationLocationsInplace(payload.annotations);
132
+ result.annotations = payload.annotations;
133
+ test.annotations = payload.annotations;
134
+ }
135
+ this._reporter.onTestEnd?.(test, result);
136
+ result._stepMap = /* @__PURE__ */ new Map();
137
+ }
138
+ _onStepBegin(testId, resultId, payload) {
139
+ const test = this._tests.get(testId);
140
+ const result = test.results.find((r) => r._id === resultId);
141
+ const parentStep = payload.parentStepId ? result._stepMap.get(payload.parentStepId) : void 0;
142
+ const location = this._absoluteLocation(payload.location);
143
+ const step = new TeleTestStep(payload, parentStep, location, result);
144
+ if (parentStep)
145
+ parentStep.steps.push(step);
146
+ else
147
+ result.steps.push(step);
148
+ result._stepMap.set(payload.id, step);
149
+ this._reporter.onStepBegin?.(test, result, step);
150
+ }
151
+ _onStepEnd(testId, resultId, payload) {
152
+ const test = this._tests.get(testId);
153
+ const result = test.results.find((r) => r._id === resultId);
154
+ const step = result._stepMap.get(payload.id);
155
+ step._endPayload = payload;
156
+ step.duration = payload.duration;
157
+ step.error = payload.error;
158
+ this._reporter.onStepEnd?.(test, result, step);
159
+ }
160
+ _onAttach(testId, resultId, attachments) {
161
+ const test = this._tests.get(testId);
162
+ const result = test.results.find((r) => r._id === resultId);
163
+ result.attachments.push(...attachments.map((a) => ({
164
+ name: a.name,
165
+ contentType: a.contentType,
166
+ path: a.path,
167
+ body: a.base64 && globalThis.Buffer ? Buffer.from(a.base64, "base64") : void 0
168
+ })));
169
+ }
170
+ _onError(error) {
171
+ this._reporter.onError?.(error);
172
+ }
173
+ _onStdIO(type, testId, resultId, data, isBase64) {
174
+ const chunk = isBase64 ? globalThis.Buffer ? Buffer.from(data, "base64") : atob(data) : data;
175
+ const test = testId ? this._tests.get(testId) : void 0;
176
+ const result = test && resultId ? test.results.find((r) => r._id === resultId) : void 0;
177
+ if (type === "stdout") {
178
+ result?.stdout.push(chunk);
179
+ this._reporter.onStdOut?.(chunk, test, result);
180
+ } else {
181
+ result?.stderr.push(chunk);
182
+ this._reporter.onStdErr?.(chunk, test, result);
183
+ }
184
+ }
185
+ async _onEnd(result) {
186
+ await this._reporter.onEnd?.({
187
+ status: result.status,
188
+ startTime: new Date(result.startTime),
189
+ duration: result.duration
190
+ });
191
+ }
192
+ _onExit() {
193
+ return this._reporter.onExit?.();
194
+ }
195
+ _parseConfig(config) {
196
+ const result = { ...baseFullConfig, ...config };
197
+ if (this._options.configOverrides) {
198
+ result.configFile = this._options.configOverrides.configFile;
199
+ result.reportSlowTests = this._options.configOverrides.reportSlowTests;
200
+ result.quiet = this._options.configOverrides.quiet;
201
+ result.reporter = [...this._options.configOverrides.reporter];
202
+ }
203
+ return result;
204
+ }
205
+ _parseProject(project) {
206
+ return {
207
+ metadata: project.metadata,
208
+ name: project.name,
209
+ outputDir: this._absolutePath(project.outputDir),
210
+ repeatEach: project.repeatEach,
211
+ retries: project.retries,
212
+ testDir: this._absolutePath(project.testDir),
213
+ testIgnore: parseRegexPatterns(project.testIgnore),
214
+ testMatch: parseRegexPatterns(project.testMatch),
215
+ timeout: project.timeout,
216
+ grep: parseRegexPatterns(project.grep),
217
+ grepInvert: parseRegexPatterns(project.grepInvert),
218
+ dependencies: project.dependencies,
219
+ teardown: project.teardown,
220
+ snapshotDir: this._absolutePath(project.snapshotDir),
221
+ use: project.use
222
+ };
223
+ }
224
+ _parseAttachments(attachments) {
225
+ return attachments.map((a) => {
226
+ return {
227
+ ...a,
228
+ body: a.base64 && globalThis.Buffer ? Buffer.from(a.base64, "base64") : void 0
229
+ };
230
+ });
231
+ }
232
+ _mergeSuiteInto(jsonSuite, parent) {
233
+ let targetSuite = parent.suites.find((s) => s.title === jsonSuite.title);
234
+ if (!targetSuite) {
235
+ targetSuite = new TeleSuite(jsonSuite.title, parent.type === "project" ? "file" : "describe");
236
+ parent._addSuite(targetSuite);
237
+ }
238
+ targetSuite.location = this._absoluteLocation(jsonSuite.location);
239
+ jsonSuite.entries.forEach((e) => {
240
+ if ("testId" in e)
241
+ this._mergeTestInto(e, targetSuite);
242
+ else
243
+ this._mergeSuiteInto(e, targetSuite);
244
+ });
245
+ }
246
+ _mergeTestInto(jsonTest, parent) {
247
+ let targetTest = this._options.mergeTestCases ? parent.tests.find((s) => s.title === jsonTest.title && s.repeatEachIndex === jsonTest.repeatEachIndex) : void 0;
248
+ if (!targetTest) {
249
+ targetTest = new TeleTestCase(jsonTest.testId, jsonTest.title, this._absoluteLocation(jsonTest.location), jsonTest.repeatEachIndex);
250
+ parent._addTest(targetTest);
251
+ this._tests.set(targetTest.id, targetTest);
252
+ }
253
+ this._updateTest(jsonTest, targetTest);
254
+ }
255
+ _updateTest(payload, test) {
256
+ test.id = payload.testId;
257
+ test.location = this._absoluteLocation(payload.location);
258
+ test.retries = payload.retries;
259
+ test.tags = payload.tags ?? [];
260
+ test.annotations = payload.annotations ?? [];
261
+ this._absoluteAnnotationLocationsInplace(test.annotations);
262
+ return test;
263
+ }
264
+ _absoluteAnnotationLocationsInplace(annotations) {
265
+ for (const annotation of annotations) {
266
+ if (annotation.location)
267
+ annotation.location = this._absoluteLocation(annotation.location);
268
+ }
269
+ }
270
+ _absoluteLocation(location) {
271
+ if (!location)
272
+ return location;
273
+ return {
274
+ ...location,
275
+ file: this._absolutePath(location.file)
276
+ };
277
+ }
278
+ _absolutePath(relativePath) {
279
+ if (relativePath === void 0)
280
+ return;
281
+ return this._options.resolvePath ? this._options.resolvePath(this._rootDir, relativePath) : this._rootDir + "/" + relativePath;
282
+ }
283
+ }
284
+ class TeleSuite {
285
+ constructor(title, type) {
286
+ this._entries = [];
287
+ this._requireFile = "";
288
+ this._parallelMode = "none";
289
+ this.title = title;
290
+ this._type = type;
291
+ }
292
+ get type() {
293
+ return this._type;
294
+ }
295
+ get suites() {
296
+ return this._entries.filter((e) => e.type !== "test");
297
+ }
298
+ get tests() {
299
+ return this._entries.filter((e) => e.type === "test");
300
+ }
301
+ entries() {
302
+ return this._entries;
303
+ }
304
+ allTests() {
305
+ const result = [];
306
+ const visit = (suite) => {
307
+ for (const entry of suite.entries()) {
308
+ if (entry.type === "test")
309
+ result.push(entry);
310
+ else
311
+ visit(entry);
312
+ }
313
+ };
314
+ visit(this);
315
+ return result;
316
+ }
317
+ titlePath() {
318
+ const titlePath = this.parent ? this.parent.titlePath() : [];
319
+ if (this.title || this._type !== "describe")
320
+ titlePath.push(this.title);
321
+ return titlePath;
322
+ }
323
+ project() {
324
+ return this._project ?? this.parent?.project();
325
+ }
326
+ _addTest(test) {
327
+ test.parent = this;
328
+ this._entries.push(test);
329
+ }
330
+ _addSuite(suite) {
331
+ suite.parent = this;
332
+ this._entries.push(suite);
333
+ }
334
+ }
335
+ class TeleTestCase {
336
+ constructor(id, title, location, repeatEachIndex) {
337
+ this.fn = () => {
338
+ };
339
+ this.results = [];
340
+ this.type = "test";
341
+ this.expectedStatus = "passed";
342
+ this.timeout = 0;
343
+ this.annotations = [];
344
+ this.retries = 0;
345
+ this.tags = [];
346
+ this.repeatEachIndex = 0;
347
+ this.id = id;
348
+ this.title = title;
349
+ this.location = location;
350
+ this.repeatEachIndex = repeatEachIndex;
351
+ }
352
+ titlePath() {
353
+ const titlePath = this.parent ? this.parent.titlePath() : [];
354
+ titlePath.push(this.title);
355
+ return titlePath;
356
+ }
357
+ outcome() {
358
+ return computeTestCaseOutcome(this);
359
+ }
360
+ ok() {
361
+ const status = this.outcome();
362
+ return status === "expected" || status === "flaky" || status === "skipped";
363
+ }
364
+ _createTestResult(id) {
365
+ const result = new TeleTestResult(this.results.length, id);
366
+ this.results.push(result);
367
+ return result;
368
+ }
369
+ }
370
+ class TeleTestStep {
371
+ constructor(payload, parentStep, location, result) {
372
+ this.duration = -1;
373
+ this.steps = [];
374
+ this._startTime = 0;
375
+ this.title = payload.title;
376
+ this.category = payload.category;
377
+ this.location = location;
378
+ this.parent = parentStep;
379
+ this._startTime = payload.startTime;
380
+ this._result = result;
381
+ }
382
+ titlePath() {
383
+ const parentPath = this.parent?.titlePath() || [];
384
+ return [...parentPath, this.title];
385
+ }
386
+ get startTime() {
387
+ return new Date(this._startTime);
388
+ }
389
+ set startTime(value) {
390
+ this._startTime = +value;
391
+ }
392
+ get attachments() {
393
+ return this._endPayload?.attachments?.map((index) => this._result.attachments[index]) ?? [];
394
+ }
395
+ get annotations() {
396
+ return this._endPayload?.annotations ?? [];
397
+ }
398
+ }
399
+ class TeleTestResult {
400
+ constructor(retry, id) {
401
+ this.parallelIndex = -1;
402
+ this.workerIndex = -1;
403
+ this.duration = -1;
404
+ this.stdout = [];
405
+ this.stderr = [];
406
+ this.attachments = [];
407
+ this.annotations = [];
408
+ this.status = "skipped";
409
+ this.steps = [];
410
+ this.errors = [];
411
+ this._stepMap = /* @__PURE__ */ new Map();
412
+ this._startTime = 0;
413
+ this.retry = retry;
414
+ this._id = id;
415
+ }
416
+ setStartTimeNumber(startTime) {
417
+ this._startTime = startTime;
418
+ }
419
+ get startTime() {
420
+ return new Date(this._startTime);
421
+ }
422
+ set startTime(value) {
423
+ this._startTime = +value;
424
+ }
425
+ }
426
+ const baseFullConfig = {
427
+ forbidOnly: false,
428
+ fullyParallel: false,
429
+ globalSetup: null,
430
+ globalTeardown: null,
431
+ globalTimeout: 0,
432
+ grep: /.*/,
433
+ grepInvert: null,
434
+ maxFailures: 0,
435
+ metadata: {},
436
+ preserveOutput: "always",
437
+ projects: [],
438
+ reporter: [[process.env.CI ? "dot" : "list"]],
439
+ reportSlowTests: {
440
+ max: 5,
441
+ threshold: 3e5
442
+ /* 5 minutes */
443
+ },
444
+ configFile: "",
445
+ rootDir: "",
446
+ quiet: false,
447
+ shard: null,
448
+ updateSnapshots: "missing",
449
+ updateSourceMethod: "patch",
450
+ version: "",
451
+ workers: 0,
452
+ webServer: null
453
+ };
454
+ function serializeRegexPatterns(patterns) {
455
+ if (!Array.isArray(patterns))
456
+ patterns = [patterns];
457
+ return patterns.map((s) => {
458
+ if (typeof s === "string")
459
+ return { s };
460
+ return { r: { source: s.source, flags: s.flags } };
461
+ });
462
+ }
463
+ function parseRegexPatterns(patterns) {
464
+ return patterns.map((p) => {
465
+ if (p.s !== void 0)
466
+ return p.s;
467
+ return new RegExp(p.r.source, p.r.flags);
468
+ });
469
+ }
470
+ function computeTestCaseOutcome(test) {
471
+ let skipped = 0;
472
+ let didNotRun = 0;
473
+ let expected = 0;
474
+ let interrupted = 0;
475
+ let unexpected = 0;
476
+ for (const result of test.results) {
477
+ if (result.status === "interrupted") {
478
+ ++interrupted;
479
+ } else if (result.status === "skipped" && test.expectedStatus === "skipped") {
480
+ ++skipped;
481
+ } else if (result.status === "skipped") {
482
+ ++didNotRun;
483
+ } else if (result.status === test.expectedStatus) {
484
+ ++expected;
485
+ } else {
486
+ ++unexpected;
487
+ }
488
+ }
489
+ if (expected === 0 && unexpected === 0)
490
+ return "skipped";
491
+ if (unexpected === 0)
492
+ return "expected";
493
+ if (expected === 0 && skipped === 0)
494
+ return "unexpected";
495
+ return "flaky";
496
+ }
497
+ // Annotate the CommonJS export names for ESM import in node:
498
+ 0 && (module.exports = {
499
+ TeleReporterReceiver,
500
+ TeleSuite,
501
+ TeleTestCase,
502
+ TeleTestResult,
503
+ baseFullConfig,
504
+ computeTestCaseOutcome,
505
+ parseRegexPatterns,
506
+ serializeRegexPatterns
507
+ });
@@ -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
+ });