@epicat/toon-reporter 0.0.6 → 0.0.7
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/dist/index.d.mts +1 -1
- package/dist/index.mjs +34 -16
- package/dist/playwright.d.mts +0 -1
- package/dist/playwright.mjs +1 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -11,7 +11,6 @@ interface ToonReporterOptions {
|
|
|
11
11
|
_captureOutput?: (output: string) => void;
|
|
12
12
|
}
|
|
13
13
|
declare class ToonReporter implements Reporter {
|
|
14
|
-
start: number;
|
|
15
14
|
ctx: Vitest;
|
|
16
15
|
options: ToonReporterOptions;
|
|
17
16
|
private useColor;
|
|
@@ -25,6 +24,7 @@ declare class ToonReporter implements Reporter {
|
|
|
25
24
|
private parseErrorLocation;
|
|
26
25
|
private parseExpectedGot;
|
|
27
26
|
private formatErrorMessage;
|
|
27
|
+
private buildReportForModules;
|
|
28
28
|
onTestRunEnd(testModules: ReadonlyArray<any>, _unhandledErrors: ReadonlyArray<SerializedError>, _reason: TestRunEndReason): Promise<void>;
|
|
29
29
|
private colorize;
|
|
30
30
|
writeReport(report: string): Promise<void>;
|
package/dist/index.mjs
CHANGED
|
@@ -47,13 +47,11 @@ function shouldUseColor(option) {
|
|
|
47
47
|
}
|
|
48
48
|
var ToonReporter = class {
|
|
49
49
|
constructor(options = {}) {
|
|
50
|
-
this.start = 0;
|
|
51
50
|
this.options = options;
|
|
52
51
|
this.useColor = shouldUseColor(options.color);
|
|
53
52
|
}
|
|
54
53
|
onInit(ctx) {
|
|
55
54
|
this.ctx = ctx;
|
|
56
|
-
this.start = Date.now();
|
|
57
55
|
this.coverageMap = void 0;
|
|
58
56
|
const coverage = ctx.config.coverage;
|
|
59
57
|
if (coverage?.reporter) coverage.reporter = [];
|
|
@@ -150,8 +148,8 @@ var ToonReporter = class {
|
|
|
150
148
|
if (name && name !== "Error" && !message.startsWith(name)) message = `${name}: ${message}`;
|
|
151
149
|
return message;
|
|
152
150
|
}
|
|
153
|
-
|
|
154
|
-
const tests = getTests(
|
|
151
|
+
buildReportForModules(modules) {
|
|
152
|
+
const tests = getTests(modules.map((m) => m.task));
|
|
155
153
|
const rootDir = this.ctx.config.root;
|
|
156
154
|
const failedTests = tests.filter((t) => t.result?.state === "fail");
|
|
157
155
|
const passedCount = tests.filter((t) => t.result?.state === "pass").length;
|
|
@@ -165,20 +163,17 @@ var ToonReporter = class {
|
|
|
165
163
|
const { expected, got } = this.parseExpectedGot(error);
|
|
166
164
|
const relPath = loc?.relPath || relative(rootDir, t.file.filepath);
|
|
167
165
|
const at = this.formatLocation(relPath, loc?.line || t.location?.line, loc?.column || t.location?.column);
|
|
166
|
+
const failureDetails = expected !== void 0 && got !== void 0 ? {
|
|
167
|
+
expected,
|
|
168
|
+
got
|
|
169
|
+
} : { error: this.formatErrorMessage(error) };
|
|
168
170
|
if (t.each) {
|
|
169
171
|
if (!grouped.has(at)) grouped.set(at, []);
|
|
170
|
-
grouped.get(at).push(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
const failure = { at };
|
|
176
|
-
if (expected !== void 0 && got !== void 0) {
|
|
177
|
-
failure.expected = expected;
|
|
178
|
-
failure.got = got;
|
|
179
|
-
} else if (error) failure.error = this.formatErrorMessage(error);
|
|
180
|
-
failures.push(failure);
|
|
181
|
-
}
|
|
172
|
+
grouped.get(at).push(failureDetails);
|
|
173
|
+
} else failures.push({
|
|
174
|
+
at,
|
|
175
|
+
...failureDetails
|
|
176
|
+
});
|
|
182
177
|
}
|
|
183
178
|
for (const [at, params] of grouped) failures.push({
|
|
184
179
|
at,
|
|
@@ -192,6 +187,29 @@ var ToonReporter = class {
|
|
|
192
187
|
if (failures.length > 0) report.failing = failures;
|
|
193
188
|
if (todoTests.length > 0) report.todo = todoTests.map(mapToSkipped);
|
|
194
189
|
if (skippedTests.length > 0) report.skipped = skippedTests.map(mapToSkipped);
|
|
190
|
+
return report;
|
|
191
|
+
}
|
|
192
|
+
async onTestRunEnd(testModules, _unhandledErrors, _reason) {
|
|
193
|
+
const projectNames = /* @__PURE__ */ new Set();
|
|
194
|
+
const modulesByProject = /* @__PURE__ */ new Map();
|
|
195
|
+
for (const m of testModules) {
|
|
196
|
+
const projectName = m.project?.name || "";
|
|
197
|
+
projectNames.add(projectName);
|
|
198
|
+
if (!modulesByProject.has(projectName)) modulesByProject.set(projectName, []);
|
|
199
|
+
modulesByProject.get(projectName).push(m);
|
|
200
|
+
}
|
|
201
|
+
if (projectNames.size > 1) {
|
|
202
|
+
const projectReports = {};
|
|
203
|
+
for (const [projectName, modules] of modulesByProject) projectReports[projectName || "default"] = this.buildReportForModules(modules);
|
|
204
|
+
const coverage$1 = this.getCoverageSummary();
|
|
205
|
+
if (coverage$1) await this.writeReport(encode({
|
|
206
|
+
...projectReports,
|
|
207
|
+
coverage: coverage$1
|
|
208
|
+
}));
|
|
209
|
+
else await this.writeReport(encode(projectReports));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const report = this.buildReportForModules([...testModules]);
|
|
195
213
|
const coverage = this.getCoverageSummary();
|
|
196
214
|
if (coverage) report.coverage = coverage;
|
|
197
215
|
await this.writeReport(encode(report));
|
package/dist/playwright.d.mts
CHANGED
|
@@ -12,7 +12,6 @@ declare class ToonPlaywrightReporter implements Reporter {
|
|
|
12
12
|
private options;
|
|
13
13
|
constructor(options?: ToonPlaywrightReporterOptions);
|
|
14
14
|
onBegin(config: FullConfig, suite: Suite): void;
|
|
15
|
-
private get rootDir();
|
|
16
15
|
private formatLocation;
|
|
17
16
|
private stripAnsi;
|
|
18
17
|
private stripOuterQuotes;
|
package/dist/playwright.mjs
CHANGED
|
@@ -11,11 +11,8 @@ var ToonPlaywrightReporter = class {
|
|
|
11
11
|
this.config = config;
|
|
12
12
|
this.suite = suite;
|
|
13
13
|
}
|
|
14
|
-
get rootDir() {
|
|
15
|
-
return this.config.rootDir;
|
|
16
|
-
}
|
|
17
14
|
formatLocation(filePath, line, column) {
|
|
18
|
-
const relPath = relative(
|
|
15
|
+
const relPath = relative(process.cwd(), filePath);
|
|
19
16
|
return line ? `${relPath}:${line}:${column || 0}` : relPath;
|
|
20
17
|
}
|
|
21
18
|
stripAnsi(str) {
|