@epicat/toon-reporter 0.0.1

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +156 -0
  3. package/package.json +47 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tom Siwik
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,156 @@
1
+ # toon-reporter
2
+
3
+ A minimal Vitest reporter optimized for LLM consumption. Outputs test results in a compact, token-efficient format.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @epicat/toon-reporter
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### CLI
14
+
15
+ ```bash
16
+ npx vitest run --reporter=@epicat/toon-reporter
17
+ ```
18
+
19
+ ### Config
20
+
21
+ ```ts
22
+ // vitest.config.ts
23
+ import { defineConfig } from 'vitest/config'
24
+
25
+ export default defineConfig({
26
+ test: {
27
+ reporters: ['@epicat/toon-reporter'],
28
+ },
29
+ })
30
+ ```
31
+
32
+ ## Output Format
33
+
34
+ ### All tests passing
35
+
36
+ ```
37
+ passing: 42
38
+ ```
39
+
40
+ ### With failures
41
+
42
+ ```
43
+ passing: 40
44
+ failing[2]:
45
+ - at: src/utils.test.ts:15:12
46
+ expected: "7"
47
+ got: "6"
48
+ - at: src/api.test.ts:42:8
49
+ error: TypeError: Cannot read property 'id' of undefined
50
+ ```
51
+
52
+ ### With parameterized test failures
53
+
54
+ Uses TOON tabular format for uniform parameter arrays:
55
+
56
+ ```
57
+ passing: 6
58
+ failing[2]:
59
+ - at: math.test.ts:16:17
60
+ parameters[2]{expected,got}:
61
+ "1","2"
62
+ "4","2"
63
+ ```
64
+
65
+ ### With todo/skipped tests
66
+
67
+ Uses TOON tabular format for uniform arrays:
68
+
69
+ ```
70
+ passing: 38
71
+ todo[1]{at,name}:
72
+ src/api.test.ts,implement error handling
73
+ skipped[2]{at,name}:
74
+ src/utils.test.ts,handles edge case
75
+ ```
76
+
77
+ ## Colors
78
+
79
+ - **Green**: `passing` count
80
+ - **Red**: `failing` header
81
+ - **Yellow**: file paths
82
+ - **Gray**: `skipped` tests
83
+ - **Cyan**: `todo` tests
84
+
85
+ Colors are automatically disabled when:
86
+ - `NO_COLOR` environment variable is set
87
+ - `CI` environment variable is set
88
+ - Output is written to a file
89
+
90
+ ## Options
91
+
92
+ ### `color`
93
+
94
+ Enable/disable colored output (default: `false`).
95
+
96
+ ```ts
97
+ // vitest.config.ts
98
+ import { defineConfig } from 'vitest/config'
99
+ import { ToonReporter } from '@epicat/toon-reporter'
100
+
101
+ export default defineConfig({
102
+ test: {
103
+ reporters: [new ToonReporter({ color: true })],
104
+ },
105
+ })
106
+ ```
107
+
108
+ ### `outputFile`
109
+
110
+ Write report to a file instead of stdout.
111
+
112
+ ```ts
113
+ reporters: [['toon-reporter', { outputFile: 'test-results.txt' }]]
114
+ ```
115
+
116
+ ## Skipped/Todo Line Numbers
117
+
118
+ To get line:column information for skipped and todo tests, enable `includeTaskLocation` in your vitest config:
119
+
120
+ ```ts
121
+ // vitest.config.ts
122
+ export default defineConfig({
123
+ test: {
124
+ includeTaskLocation: true,
125
+ reporters: ['toon-reporter'],
126
+ },
127
+ })
128
+ ```
129
+
130
+ Or via CLI:
131
+
132
+ ```bash
133
+ npx vitest run --reporter=toon-reporter --includeTaskLocation
134
+ ```
135
+
136
+ Without this option, skipped/todo tests will only show the file path (not line:column). This is a Vitest limitation - test locations are only collected when this config is enabled before test collection.
137
+
138
+ ## Why?
139
+
140
+ Traditional test reporters output verbose information optimized for human readability. When feeding test results to an LLM for automated fixing, this verbosity wastes tokens. This reporter outputs only what's needed:
141
+
142
+ - Pass count
143
+ - Failure locations with expected/got values
144
+ - Skipped/todo test names for context
145
+
146
+ ## Token Efficiency
147
+
148
+ Measured on a test suite with 25 tests (16 passing, 7 failing, 1 skipped, 1 todo):
149
+
150
+ | Reporter | Tokens | vs Default | vs JSON |
151
+ |----------|-------:|:----------:|:-------:|
152
+ | default | 4,884 | - | -10% |
153
+ | json | 5,418 | +11% | - |
154
+ | **toon** | **212** | **-96%** | **-96%** |
155
+
156
+ TOON uses ~96% fewer tokens than standard reporters.
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@epicat/toon-reporter",
3
+ "version": "0.0.1",
4
+ "description": "A minimal Vitest reporter optimized for LLM consumption",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/tomsiwik/toon-reporter.git"
8
+ },
9
+ "license": "MIT",
10
+ "type": "module",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "main": "./dist/index.mjs",
15
+ "module": "./dist/index.mjs",
16
+ "types": "./dist/index.d.mts",
17
+ "exports": {
18
+ ".": "./dist/index.mjs",
19
+ "./package.json": "./package.json"
20
+ },
21
+ "scripts": {
22
+ "build": "tsdown",
23
+ "dev": "tsdown --watch",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest"
26
+ },
27
+ "devDependencies": {
28
+ "@changesets/cli": "^2.29.8",
29
+ "@types/istanbul-lib-coverage": "^2.0.6",
30
+ "@types/node": "^24.10.1",
31
+ "@vitest/runner": "4.0.15",
32
+ "@vitest/snapshot": "4.0.15",
33
+ "@vitest/utils": "4.0.15",
34
+ "execa": "^9.6.1",
35
+ "gpt-tokenizer": "^3.4.0",
36
+ "istanbul-lib-coverage": "^3.2.2",
37
+ "pathe": "^2.0.3",
38
+ "tsdown": "^0.16.4",
39
+ "typescript": "^5.9.3",
40
+ "vite": "^7.2.6",
41
+ "vitest": "4.0.15"
42
+ },
43
+ "packageManager": "pnpm@10.22.0+sha512.bf049efe995b28f527fd2b41ae0474ce29186f7edcb3bf545087bd61fbbebb2bf75362d1307fda09c2d288e1e499787ac12d4fcb617a974718a6051f2eee741c",
44
+ "dependencies": {
45
+ "@toon-format/toon": "^2.0.1"
46
+ }
47
+ }