vitest-ai-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.
- package/README.md +46 -0
- package/dist/index.cjs +68 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +47 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# vitest-ai-reporter
|
|
2
|
+
|
|
3
|
+
A minimal Vitest reporter designed for AI coding tools — shows only what matters: pass count or failed test details.
|
|
4
|
+
|
|
5
|
+
## Output
|
|
6
|
+
|
|
7
|
+
All tests pass:
|
|
8
|
+
```
|
|
9
|
+
PASS (12) FAIL (0)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Some tests fail:
|
|
13
|
+
```
|
|
14
|
+
PASS (11) FAIL (1)
|
|
15
|
+
|
|
16
|
+
✗ src/math.test.ts > add > returns correct sum
|
|
17
|
+
→ expected 2 to be 3 // Object.is equality
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -D vitest-ai-reporter
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
// vitest.config.ts
|
|
30
|
+
import { defineConfig } from 'vitest/config'
|
|
31
|
+
import AIReporter from 'vitest-ai-reporter'
|
|
32
|
+
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
test: {
|
|
35
|
+
reporters: [new AIReporter()],
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Why
|
|
41
|
+
|
|
42
|
+
Default Vitest output is verbose and hard to parse programmatically. This reporter strips everything down to a compact format that is easy to read in LLM context windows.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
default: () => AIReporter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
function collectTests(children, ancestry, filePath, stats) {
|
|
27
|
+
for (const child of children) {
|
|
28
|
+
if (child.type === "test") {
|
|
29
|
+
const result = child.result();
|
|
30
|
+
if (result.state === "failed") {
|
|
31
|
+
stats.failed++;
|
|
32
|
+
const msg = result.errors?.[0]?.message ?? "Unknown error";
|
|
33
|
+
stats.failures.push({
|
|
34
|
+
name: [...ancestry, child.name].join(" > "),
|
|
35
|
+
file: filePath,
|
|
36
|
+
error: msg
|
|
37
|
+
});
|
|
38
|
+
} else if (result.state === "passed") {
|
|
39
|
+
stats.passed++;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
collectTests(child.children, [...ancestry, child.name], filePath, stats);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
var AIReporter = class {
|
|
47
|
+
onTestRunEnd(testModules) {
|
|
48
|
+
const stats = { passed: 0, failed: 0, failures: [] };
|
|
49
|
+
for (const module2 of testModules) {
|
|
50
|
+
collectTests(module2.children, [], module2.relativeModuleId, stats);
|
|
51
|
+
}
|
|
52
|
+
if (stats.failed === 0) {
|
|
53
|
+
process.stdout.write(`PASS (${stats.passed}) FAIL (0)
|
|
54
|
+
`);
|
|
55
|
+
} else {
|
|
56
|
+
process.stdout.write(`PASS (${stats.passed}) FAIL (${stats.failed})
|
|
57
|
+
|
|
58
|
+
`);
|
|
59
|
+
for (const f of stats.failures) {
|
|
60
|
+
const indented = f.error.split("\n").join("\n ");
|
|
61
|
+
process.stdout.write(`\u25CF ${f.file} > ${f.name}
|
|
62
|
+
${indented}
|
|
63
|
+
|
|
64
|
+
`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function collectTests(children, ancestry, filePath, stats) {
|
|
3
|
+
for (const child of children) {
|
|
4
|
+
if (child.type === "test") {
|
|
5
|
+
const result = child.result();
|
|
6
|
+
if (result.state === "failed") {
|
|
7
|
+
stats.failed++;
|
|
8
|
+
const msg = result.errors?.[0]?.message ?? "Unknown error";
|
|
9
|
+
stats.failures.push({
|
|
10
|
+
name: [...ancestry, child.name].join(" > "),
|
|
11
|
+
file: filePath,
|
|
12
|
+
error: msg
|
|
13
|
+
});
|
|
14
|
+
} else if (result.state === "passed") {
|
|
15
|
+
stats.passed++;
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
collectTests(child.children, [...ancestry, child.name], filePath, stats);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
var AIReporter = class {
|
|
23
|
+
onTestRunEnd(testModules) {
|
|
24
|
+
const stats = { passed: 0, failed: 0, failures: [] };
|
|
25
|
+
for (const module of testModules) {
|
|
26
|
+
collectTests(module.children, [], module.relativeModuleId, stats);
|
|
27
|
+
}
|
|
28
|
+
if (stats.failed === 0) {
|
|
29
|
+
process.stdout.write(`PASS (${stats.passed}) FAIL (0)
|
|
30
|
+
`);
|
|
31
|
+
} else {
|
|
32
|
+
process.stdout.write(`PASS (${stats.passed}) FAIL (${stats.failed})
|
|
33
|
+
|
|
34
|
+
`);
|
|
35
|
+
for (const f of stats.failures) {
|
|
36
|
+
const indented = f.error.split("\n").join("\n ");
|
|
37
|
+
process.stdout.write(`\u25CF ${f.file} > ${f.name}
|
|
38
|
+
${indented}
|
|
39
|
+
|
|
40
|
+
`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
AIReporter as default
|
|
47
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vitest-ai-reporter",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "AI Vitest reporter — shows only pass count or failed test details",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"import": "./dist/index.js",
|
|
8
|
+
"require": "./dist/index.cjs"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.cjs",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
15
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"vitest": ">=1.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^25.5.2",
|
|
24
|
+
"tsup": "^8.5.1",
|
|
25
|
+
"typescript": "^6.0.2",
|
|
26
|
+
"vitest": "^4.1.2"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"keywords": [
|
|
32
|
+
"vitest",
|
|
33
|
+
"reporter",
|
|
34
|
+
"minimal",
|
|
35
|
+
"ai"
|
|
36
|
+
],
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"author": {
|
|
39
|
+
"name": "Youssouf El Azizi",
|
|
40
|
+
"url": "https://github.com/yjose"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/yjose/vitest-ai-reporter.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/yjose/vitest-ai-reporter/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/yjose/vitest-ai-reporter#readme"
|
|
50
|
+
}
|