|
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: createPathResolve(options.pathSeparator), |
|
40
|
clearPreviousResultsWhenTestBegins: true |
|
41
|
}); |
|
42
|
this._options = options; |
|
43
|
} |
|
44
|
_createReporter() { |
|
45
|
return { |
|
46
|
version: () => "v2", |
|
47
|
onConfigure: (config) => { |
|
48
|
this.config = config; |
|
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: createPathResolve(this._options.pathSeparator) |
|
59
|
}); |
|
60
|
void this._lastRunReceiver.dispatch({ method: "onConfigure", params: { config } }); |
|
61
|
}, |
|
62
|
onBegin: (suite) => { |
|
63
|
if (!this.rootSuite) |
|
64
|
this.rootSuite = suite; |
|
65
|
if (this._testResultsSnapshot) { |
|
66
|
for (const test of this.rootSuite.allTests()) |
|
67
|
test.results = this._testResultsSnapshot?.get(test.id) || test.results; |
|
68
|
this._testResultsSnapshot = void 0; |
|
69
|
} |
|
70
|
this.progress.total = this._lastRunTestCount; |
|
71
|
this.progress.passed = 0; |
|
72
|
this.progress.failed = 0; |
|
73
|
this.progress.skipped = 0; |
|
74
|
this._options.onUpdate(true); |
|
75
|
}, |
|
76
|
onEnd: () => { |
|
77
|
this._options.onUpdate(true); |
|
78
|
}, |
|
79
|
onTestBegin: (test, testResult) => { |
|
80
|
testResult[import_testTree.statusEx] = "running"; |
|
81
|
this._options.onUpdate(); |
|
82
|
}, |
|
83
|
onTestEnd: (test, testResult) => { |
|
84
|
if (test.outcome() === "skipped") |
|
85
|
++this.progress.skipped; |
|
86
|
else if (test.outcome() === "unexpected") |
|
87
|
++this.progress.failed; |
|
88
|
else |
|
89
|
++this.progress.passed; |
|
90
|
testResult[import_testTree.statusEx] = testResult.status; |
|
91
|
this._options.onUpdate(); |
|
92
|
}, |
|
93
|
onError: (error) => this._handleOnError(error), |
|
94
|
printsToStdio: () => false |
|
95
|
}; |
|
96
|
} |
|
97
|
processGlobalReport(report) { |
|
98
|
const receiver = new import_teleReceiver.TeleReporterReceiver({ |
|
99
|
version: () => "v2", |
|
100
|
onConfigure: (c) => { |
|
101
|
this.config = c; |
|
102
|
}, |
|
103
|
onError: (error) => this._handleOnError(error) |
|
104
|
}); |
|
105
|
for (const message of report) |
|
106
|
void receiver.dispatch(message); |
|
107
|
} |
|
108
|
processListReport(report) { |
|
109
|
const tests = this.rootSuite?.allTests() || []; |
|
110
|
this._testResultsSnapshot = new Map(tests.map((test) => [test.id, test.results])); |
|
111
|
this._receiver.reset(); |
|
112
|
for (const message of report) |
|
113
|
void this._receiver.dispatch(message); |
|
114
|
} |
|
115
|
processTestReportEvent(message) { |
|
116
|
this._lastRunReceiver?.dispatch(message)?.catch(() => { |
|
117
|
}); |
|
118
|
this._receiver.dispatch(message)?.catch(() => { |
|
119
|
}); |
|
120
|
} |
|
121
|
_handleOnError(error) { |
|
122
|
this.loadErrors.push(error); |
|
123
|
this._options.onError?.(error); |
|
124
|
this._options.onUpdate(); |
|
125
|
} |
|
126
|
asModel() { |
|
127
|
return { |
|
128
|
rootSuite: this.rootSuite || new import_teleReceiver.TeleSuite("", "root"), |
|
129
|
config: this.config, |
|
130
|
loadErrors: this.loadErrors, |
|
131
|
progress: this.progress |
|
132
|
}; |
|
133
|
} |
|
134
|
} |
|
135
|
function createPathResolve(pathSeparator) { |
|
136
|
return (rootDir, relativePath) => { |
|
137
|
const segments = []; |
|
138
|
for (const segment of [...rootDir.split(pathSeparator), ...relativePath.split(pathSeparator)]) { |
|
139
|
const isAfterDrive = pathSeparator === "\\" && segments.length === 1 && segments[0].endsWith(":"); |
|
140
|
const isFirst = !segments.length; |
|
141
|
if (!segment && !isFirst && !isAfterDrive) |
|
142
|
continue; |
|
143
|
if (segment === ".") |
|
144
|
continue; |
|
145
|
if (segment === "..") { |
|
146
|
segments.pop(); |
|
147
|
continue; |
|
148
|
} |
|
149
|
segments.push(segment); |
|
150
|
} |
|
151
|
return segments.join(pathSeparator); |
|
152
|
}; |
|
153
|
} |
|
154
|
// Annotate the CommonJS export names for ESM import in node: |
|
155
|
0 && (module.exports = { |
|
156
|
TeleSuiteUpdater |
|
157
|
}); |
|
158
|
|