@epicat/toon-reporter 0.0.10 → 0.0.12

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.
@@ -12,6 +12,8 @@ declare class ToonPlaywrightReporter implements Reporter {
12
12
  private config;
13
13
  private suite;
14
14
  private options;
15
+ private testsDiscovered;
16
+ private _didBegin;
15
17
  constructor(options?: ToonPlaywrightReporterOptions);
16
18
  onBegin(config: FullConfig, suite: Suite): void;
17
19
  private formatLocation;
@@ -17,11 +17,15 @@ function formatDuration(ms) {
17
17
  }
18
18
  var ToonPlaywrightReporter = class {
19
19
  constructor(options = {}) {
20
+ this.testsDiscovered = 0;
21
+ this._didBegin = false;
20
22
  this.options = options;
21
23
  }
22
24
  onBegin(config, suite) {
23
25
  this.config = config;
24
26
  this.suite = suite;
27
+ this.testsDiscovered = suite.allTests().length;
28
+ this._didBegin = true;
25
29
  }
26
30
  formatLocation(filePath, line, column) {
27
31
  const relPath = relative(process.cwd(), filePath);
@@ -50,9 +54,19 @@ var ToonPlaywrightReporter = class {
50
54
  return {};
51
55
  }
52
56
  async onEnd(result) {
57
+ if (!this._didBegin) {
58
+ await this.writeReport(encode({ error: "Test run failed before initialization" }));
59
+ return;
60
+ }
53
61
  const allTests = this.suite.allTests();
54
62
  if (allTests.length === 0) {
55
- await this.writeReport(encode({ error: "No test files found" }));
63
+ let errorMessage;
64
+ if (this.testsDiscovered > 0) errorMessage = `${this.testsDiscovered} test(s) discovered but not executed`;
65
+ else if (result.status === "interrupted") errorMessage = "Test run was interrupted";
66
+ else if (result.status === "timedout") errorMessage = "Test run timed out";
67
+ else errorMessage = "No test files found";
68
+ const report$1 = { error: errorMessage };
69
+ await this.writeReport(encode(report$1));
56
70
  return;
57
71
  }
58
72
  const passedTests = [];
@@ -60,9 +74,11 @@ var ToonPlaywrightReporter = class {
60
74
  const skippedTests = [];
61
75
  const todoTests = [];
62
76
  const flakyTests = [];
77
+ let testsWithResults = 0;
63
78
  for (const test of allTests) {
64
79
  const lastResult = test.results[test.results.length - 1];
65
80
  if (!lastResult) continue;
81
+ testsWithResults++;
66
82
  const status = lastResult.status;
67
83
  const isFixme = test.annotations.some((a) => a.type === "fixme");
68
84
  if (status === "passed" && test.results.length > 1 && test.results.some((r) => r.status === "failed")) flakyTests.push(test);
@@ -71,6 +87,14 @@ var ToonPlaywrightReporter = class {
71
87
  else if (status === "skipped") if (isFixme) todoTests.push(test);
72
88
  else skippedTests.push(test);
73
89
  }
90
+ if (testsWithResults === 0) {
91
+ let errorMessage = `${allTests.length} test(s) discovered but not executed`;
92
+ if (result.status === "timedout") errorMessage += " (timed out)";
93
+ else if (result.status === "interrupted") errorMessage += " (interrupted)";
94
+ const report$1 = { error: errorMessage };
95
+ await this.writeReport(encode(report$1));
96
+ return;
97
+ }
74
98
  const failures = [];
75
99
  for (const test of failedTests) {
76
100
  const error = test.results[test.results.length - 1]?.errors?.[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epicat/toon-reporter",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "A minimal Vitest reporter optimized for LLM consumption",
5
5
  "repository": {
6
6
  "type": "git",