ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / isomorphic / teleSuiteUpdater.js
Source Blame History 157 lines
f7eb47b… lmata 1 "use strict";
f7eb47b… lmata 2 var __defProp = Object.defineProperty;
f7eb47b… lmata 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
f7eb47b… lmata 4 var __getOwnPropNames = Object.getOwnPropertyNames;
f7eb47b… lmata 5 var __hasOwnProp = Object.prototype.hasOwnProperty;
f7eb47b… lmata 6 var __export = (target, all) => {
f7eb47b… lmata 7 for (var name in all)
f7eb47b… lmata 8 __defProp(target, name, { get: all[name], enumerable: true });
f7eb47b… lmata 9 };
f7eb47b… lmata 10 var __copyProps = (to, from, except, desc) => {
f7eb47b… lmata 11 if (from && typeof from === "object" || typeof from === "function") {
f7eb47b… lmata 12 for (let key of __getOwnPropNames(from))
f7eb47b… lmata 13 if (!__hasOwnProp.call(to, key) && key !== except)
f7eb47b… lmata 14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
f7eb47b… lmata 15 }
f7eb47b… lmata 16 return to;
f7eb47b… lmata 17 };
f7eb47b… lmata 18 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
f7eb47b… lmata 19 var teleSuiteUpdater_exports = {};
f7eb47b… lmata 20 __export(teleSuiteUpdater_exports, {
f7eb47b… lmata 21 TeleSuiteUpdater: () => TeleSuiteUpdater
f7eb47b… lmata 22 });
f7eb47b… lmata 23 module.exports = __toCommonJS(teleSuiteUpdater_exports);
f7eb47b… lmata 24 var import_teleReceiver = require("./teleReceiver");
f7eb47b… lmata 25 var import_testTree = require("./testTree");
f7eb47b… lmata 26 class TeleSuiteUpdater {
f7eb47b… lmata 27 constructor(options) {
f7eb47b… lmata 28 this.loadErrors = [];
f7eb47b… lmata 29 this.progress = {
f7eb47b… lmata 30 total: 0,
f7eb47b… lmata 31 passed: 0,
f7eb47b… lmata 32 failed: 0,
f7eb47b… lmata 33 skipped: 0
f7eb47b… lmata 34 };
f7eb47b… lmata 35 this._lastRunTestCount = 0;
f7eb47b… lmata 36 this._receiver = new import_teleReceiver.TeleReporterReceiver(this._createReporter(), {
f7eb47b… lmata 37 mergeProjects: true,
f7eb47b… lmata 38 mergeTestCases: true,
f7eb47b… lmata 39 resolvePath: createPathResolve(options.pathSeparator),
f7eb47b… lmata 40 clearPreviousResultsWhenTestBegins: true
f7eb47b… lmata 41 });
f7eb47b… lmata 42 this._options = options;
f7eb47b… lmata 43 }
f7eb47b… lmata 44 _createReporter() {
f7eb47b… lmata 45 return {
f7eb47b… lmata 46 version: () => "v2",
f7eb47b… lmata 47 onConfigure: (config) => {
f7eb47b… lmata 48 this.config = config;
f7eb47b… lmata 49 this._lastRunReceiver = new import_teleReceiver.TeleReporterReceiver({
f7eb47b… lmata 50 version: () => "v2",
f7eb47b… lmata 51 onBegin: (suite) => {
f7eb47b… lmata 52 this._lastRunTestCount = suite.allTests().length;
f7eb47b… lmata 53 this._lastRunReceiver = void 0;
f7eb47b… lmata 54 }
f7eb47b… lmata 55 }, {
f7eb47b… lmata 56 mergeProjects: true,
f7eb47b… lmata 57 mergeTestCases: false,
f7eb47b… lmata 58 resolvePath: createPathResolve(this._options.pathSeparator)
f7eb47b… lmata 59 });
f7eb47b… lmata 60 void this._lastRunReceiver.dispatch({ method: "onConfigure", params: { config } });
f7eb47b… lmata 61 },
f7eb47b… lmata 62 onBegin: (suite) => {
f7eb47b… lmata 63 if (!this.rootSuite)
f7eb47b… lmata 64 this.rootSuite = suite;
f7eb47b… lmata 65 if (this._testResultsSnapshot) {
f7eb47b… lmata 66 for (const test of this.rootSuite.allTests())
f7eb47b… lmata 67 test.results = this._testResultsSnapshot?.get(test.id) || test.results;
f7eb47b… lmata 68 this._testResultsSnapshot = void 0;
f7eb47b… lmata 69 }
f7eb47b… lmata 70 this.progress.total = this._lastRunTestCount;
f7eb47b… lmata 71 this.progress.passed = 0;
f7eb47b… lmata 72 this.progress.failed = 0;
f7eb47b… lmata 73 this.progress.skipped = 0;
f7eb47b… lmata 74 this._options.onUpdate(true);
f7eb47b… lmata 75 },
f7eb47b… lmata 76 onEnd: () => {
f7eb47b… lmata 77 this._options.onUpdate(true);
f7eb47b… lmata 78 },
f7eb47b… lmata 79 onTestBegin: (test, testResult) => {
f7eb47b… lmata 80 testResult[import_testTree.statusEx] = "running";
f7eb47b… lmata 81 this._options.onUpdate();
f7eb47b… lmata 82 },
f7eb47b… lmata 83 onTestEnd: (test, testResult) => {
f7eb47b… lmata 84 if (test.outcome() === "skipped")
f7eb47b… lmata 85 ++this.progress.skipped;
f7eb47b… lmata 86 else if (test.outcome() === "unexpected")
f7eb47b… lmata 87 ++this.progress.failed;
f7eb47b… lmata 88 else
f7eb47b… lmata 89 ++this.progress.passed;
f7eb47b… lmata 90 testResult[import_testTree.statusEx] = testResult.status;
f7eb47b… lmata 91 this._options.onUpdate();
f7eb47b… lmata 92 },
f7eb47b… lmata 93 onError: (error) => this._handleOnError(error),
f7eb47b… lmata 94 printsToStdio: () => false
f7eb47b… lmata 95 };
f7eb47b… lmata 96 }
f7eb47b… lmata 97 processGlobalReport(report) {
f7eb47b… lmata 98 const receiver = new import_teleReceiver.TeleReporterReceiver({
f7eb47b… lmata 99 version: () => "v2",
f7eb47b… lmata 100 onConfigure: (c) => {
f7eb47b… lmata 101 this.config = c;
f7eb47b… lmata 102 },
f7eb47b… lmata 103 onError: (error) => this._handleOnError(error)
f7eb47b… lmata 104 });
f7eb47b… lmata 105 for (const message of report)
f7eb47b… lmata 106 void receiver.dispatch(message);
f7eb47b… lmata 107 }
f7eb47b… lmata 108 processListReport(report) {
f7eb47b… lmata 109 const tests = this.rootSuite?.allTests() || [];
f7eb47b… lmata 110 this._testResultsSnapshot = new Map(tests.map((test) => [test.id, test.results]));
f7eb47b… lmata 111 this._receiver.reset();
f7eb47b… lmata 112 for (const message of report)
f7eb47b… lmata 113 void this._receiver.dispatch(message);
f7eb47b… lmata 114 }
f7eb47b… lmata 115 processTestReportEvent(message) {
f7eb47b… lmata 116 this._lastRunReceiver?.dispatch(message)?.catch(() => {
f7eb47b… lmata 117 });
f7eb47b… lmata 118 this._receiver.dispatch(message)?.catch(() => {
f7eb47b… lmata 119 });
f7eb47b… lmata 120 }
f7eb47b… lmata 121 _handleOnError(error) {
f7eb47b… lmata 122 this.loadErrors.push(error);
f7eb47b… lmata 123 this._options.onError?.(error);
f7eb47b… lmata 124 this._options.onUpdate();
f7eb47b… lmata 125 }
f7eb47b… lmata 126 asModel() {
f7eb47b… lmata 127 return {
f7eb47b… lmata 128 rootSuite: this.rootSuite || new import_teleReceiver.TeleSuite("", "root"),
f7eb47b… lmata 129 config: this.config,
f7eb47b… lmata 130 loadErrors: this.loadErrors,
f7eb47b… lmata 131 progress: this.progress
f7eb47b… lmata 132 };
f7eb47b… lmata 133 }
f7eb47b… lmata 134 }
f7eb47b… lmata 135 function createPathResolve(pathSeparator) {
f7eb47b… lmata 136 return (rootDir, relativePath) => {
f7eb47b… lmata 137 const segments = [];
f7eb47b… lmata 138 for (const segment of [...rootDir.split(pathSeparator), ...relativePath.split(pathSeparator)]) {
f7eb47b… lmata 139 const isAfterDrive = pathSeparator === "\\" && segments.length === 1 && segments[0].endsWith(":");
f7eb47b… lmata 140 const isFirst = !segments.length;
f7eb47b… lmata 141 if (!segment && !isFirst && !isAfterDrive)
f7eb47b… lmata 142 continue;
f7eb47b… lmata 143 if (segment === ".")
f7eb47b… lmata 144 continue;
f7eb47b… lmata 145 if (segment === "..") {
f7eb47b… lmata 146 segments.pop();
f7eb47b… lmata 147 continue;
f7eb47b… lmata 148 }
f7eb47b… lmata 149 segments.push(segment);
f7eb47b… lmata 150 }
f7eb47b… lmata 151 return segments.join(pathSeparator);
f7eb47b… lmata 152 };
f7eb47b… lmata 153 }
f7eb47b… lmata 154 // Annotate the CommonJS export names for ESM import in node:
f7eb47b… lmata 155 0 && (module.exports = {
f7eb47b… lmata 156 TeleSuiteUpdater
f7eb47b… lmata 157 });

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button