vitest-failures-reporter 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jonathan Ong
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # vitest-failures-reporter
2
+
3
+ A minimal Vitest reporter that prints failed tests and a final summary without the noise from dot or default reporters.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ pnpm add -D vitest-failures-reporter
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```sh
14
+ vitest run --reporter=vitest-failures-reporter
15
+ ```
16
+
17
+ Use it with other reporters when CI needs annotations or artifacts:
18
+
19
+ ```sh
20
+ vitest run \
21
+ --reporter=vitest-failures-reporter \
22
+ --reporter=github-actions \
23
+ --reporter=junit \
24
+ --outputFile=test-report.junit.xml
25
+ ```
26
+
27
+ Example output:
28
+
29
+ ```txt
30
+ --- FAILED TESTS ---
31
+
32
+ FAIL math.test.mts > adds numbers
33
+ expected 1 to be 2
34
+
35
+ FAIL | 12 passed | 1 failed | 0 skipped | 3 files
36
+ ```
37
+
38
+ ## Development
39
+
40
+ ```sh
41
+ pnpm install
42
+ pnpm test
43
+ pnpm run check
44
+ ```
45
+
46
+ Tests run with this reporter as the active Vitest reporter and enforce 100% coverage for `src/`.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Minimal reporter that only prints failed tests and the final summary.
3
+ * Useful in CI where dot/default reporters produce too much noise.
4
+ */
5
+ import type { SerializedError, TestModule, TestRunEndReason } from "vitest/node";
6
+ export default class FailuresReporter {
7
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): void;
8
+ }
9
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEjF,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,YAAY,CACV,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,EACtC,eAAe,EAAE,aAAa,CAAC,eAAe,CAAC,EAC/C,MAAM,EAAE,gBAAgB;CAqF3B"}
package/dist/index.mjs ADDED
@@ -0,0 +1,83 @@
1
+ /* oxlint-disable no-console */
2
+ /**
3
+ * Minimal reporter that only prints failed tests and the final summary.
4
+ * Useful in CI where dot/default reporters produce too much noise.
5
+ */
6
+ export default class FailuresReporter {
7
+ onTestRunEnd(testModules, unhandledErrors, reason) {
8
+ let passed = 0;
9
+ let failed = 0;
10
+ let skipped = 0;
11
+ const failures = [];
12
+ const moduleFailures = [];
13
+ for (const mod of testModules) {
14
+ const moduleErrors = mod.errors();
15
+ if (mod.state() === "failed" && moduleErrors.length > 0) {
16
+ moduleFailures.push({
17
+ module: mod.moduleId,
18
+ errors: moduleErrors,
19
+ state: mod.state(),
20
+ });
21
+ }
22
+ for (const test of mod.children.allTests()) {
23
+ const result = test.result();
24
+ if (result.state === "passed") {
25
+ passed++;
26
+ }
27
+ else if (result.state === "failed") {
28
+ failed++;
29
+ failures.push({
30
+ name: test.fullName,
31
+ module: mod.moduleId,
32
+ errors: result.errors,
33
+ });
34
+ }
35
+ else {
36
+ skipped++;
37
+ }
38
+ }
39
+ }
40
+ if (moduleFailures.length > 0) {
41
+ console.error("\n--- FAILED MODULES ---\n");
42
+ for (const f of moduleFailures) {
43
+ console.error(`FAIL ${f.module} (${f.state})`);
44
+ for (const e of f.errors) {
45
+ console.error(` ${e.message}`);
46
+ if (e.stack)
47
+ console.error(e.stack);
48
+ if (e.diff)
49
+ console.error(e.diff);
50
+ }
51
+ console.error();
52
+ }
53
+ }
54
+ if (failures.length > 0) {
55
+ console.error("\n--- FAILED TESTS ---\n");
56
+ for (const f of failures) {
57
+ console.error(`FAIL ${f.module} > ${f.name}`);
58
+ for (const e of f.errors) {
59
+ console.error(` ${e.message}`);
60
+ if (e.diff)
61
+ console.error(e.diff);
62
+ }
63
+ console.error();
64
+ }
65
+ }
66
+ if (unhandledErrors.length > 0) {
67
+ console.error("\n--- UNHANDLED ERRORS ---\n");
68
+ for (const e of unhandledErrors) {
69
+ console.error(e.message);
70
+ if (e.stack)
71
+ console.error(e.stack);
72
+ console.error();
73
+ }
74
+ }
75
+ if (reason !== "passed") {
76
+ console.error(`\n--- RUN ENDED: ${reason.toUpperCase()} ---\n`);
77
+ }
78
+ const totalFailed = failed + moduleFailures.length;
79
+ const status = totalFailed > 0 || unhandledErrors.length > 0 || reason !== "passed" ? "FAIL" : "PASS";
80
+ console.log(`\n${status} | ${passed} passed | ${totalFailed} failed | ${skipped} skipped | ${testModules.length} files\n`);
81
+ }
82
+ }
83
+ //# source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C,CAAC;gBACD,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;QAED,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAC9C,KAAK,MAAM,CAAC,IAAI,eAAe,EAAE,CAAC;gBAChC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBACzB,IAAI,CAAC,CAAC,KAAK;oBAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACpC,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;QAED,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,oBAAoB,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAClE,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC;QACnD,MAAM,MAAM,GACV,WAAW,GAAG,CAAC,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;QACzF,OAAO,CAAC,GAAG,CACT,KAAK,MAAM,MAAM,MAAM,aAAa,WAAW,aAAa,OAAO,cAAc,WAAW,CAAC,MAAM,UAAU,CAC9G,CAAC;IACJ,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "vitest-failures-reporter",
3
+ "version": "0.1.0",
4
+ "description": "A minimal Vitest reporter that prints only failed tests and the final summary.",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.mts",
13
+ "default": "./dist/index.mjs"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "build": "tsc --project tsconfig.build.json",
18
+ "check": "pnpm run build && pnpm run typecheck && pnpm run lint && pnpm run test && pnpm run publint",
19
+ "check:lines": "node scripts/check-max-lines.mjs",
20
+ "lint": "pnpm run oxlint && pnpm run oxfmt:check && pnpm run actionlint && pnpm run check:lines",
21
+ "oxfmt": "oxfmt",
22
+ "oxfmt:check": "oxfmt --check",
23
+ "oxlint": "oxlint --deny-warnings",
24
+ "actionlint": "actionlint",
25
+ "publint": "pnpm run build && publint",
26
+ "test": "vitest run --coverage --reporter=./src/index.mts",
27
+ "typecheck": "tsc --noEmit"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "25.8.0",
31
+ "@vitest/coverage-v8": "4.1.6",
32
+ "actionlint": "2.0.6",
33
+ "oxfmt": "0.50.0",
34
+ "oxlint": "1.65.0",
35
+ "publint": "0.3.21",
36
+ "typescript": "6.0.3",
37
+ "vitest": "4.1.6"
38
+ },
39
+ "peerDependencies": {
40
+ "vitest": ">=4.0.0 <5"
41
+ },
42
+ "engines": {
43
+ "node": ">=24.0.0"
44
+ },
45
+ "packageManager": "pnpm@11.1.2"
46
+ }