vitest-evals 0.6.0 → 0.8.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/dist/reporter.d.mts +4 -3
- package/dist/reporter.d.ts +4 -3
- package/dist/reporter.js +35 -11
- package/dist/reporter.js.map +1 -1
- package/dist/reporter.mjs +35 -11
- package/dist/reporter.mjs.map +1 -1
- package/package.json +14 -13
package/dist/reporter.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VerboseReporter } from 'vitest/node';
|
|
2
2
|
|
|
3
|
-
declare class DefaultEvalReporter extends
|
|
4
|
-
|
|
3
|
+
declare class DefaultEvalReporter extends VerboseReporter {
|
|
4
|
+
onTestCaseResult(test: any): void;
|
|
5
|
+
private logEvalTestCase;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
export { DefaultEvalReporter as default };
|
package/dist/reporter.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VerboseReporter } from 'vitest/node';
|
|
2
2
|
|
|
3
|
-
declare class DefaultEvalReporter extends
|
|
4
|
-
|
|
3
|
+
declare class DefaultEvalReporter extends VerboseReporter {
|
|
4
|
+
onTestCaseResult(test: any): void;
|
|
5
|
+
private logEvalTestCase;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
export { DefaultEvalReporter as default };
|
package/dist/reporter.js
CHANGED
|
@@ -33,22 +33,46 @@ __export(reporter_exports, {
|
|
|
33
33
|
default: () => DefaultEvalReporter
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(reporter_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_node = require("vitest/node");
|
|
37
37
|
var import_tinyrainbow = __toESM(require("tinyrainbow"));
|
|
38
|
-
var
|
|
39
|
-
|
|
38
|
+
var TEST_NAME_SEPARATOR = import_tinyrainbow.default.dim(" > ");
|
|
39
|
+
var DefaultEvalReporter = class extends import_node.VerboseReporter {
|
|
40
|
+
onTestCaseResult(test) {
|
|
41
|
+
var _a;
|
|
40
42
|
const meta = test.meta();
|
|
41
|
-
const testResult = test.result();
|
|
42
43
|
if (!meta.eval) {
|
|
43
|
-
super.
|
|
44
|
+
super.onTestCaseResult(test);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
import_node.DefaultReporter.prototype.onTestCaseResult.call(this, test);
|
|
48
|
+
const testResult = test.result();
|
|
49
|
+
if (this.ctx.config.hideSkippedTests && testResult.state === "skipped" && ((_a = test.options) == null ? void 0 : _a.mode) !== "todo") {
|
|
44
50
|
return;
|
|
45
51
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
this.logEvalTestCase(test, meta.eval.avgScore);
|
|
53
|
+
if (testResult.state === "failed") {
|
|
54
|
+
for (const error of testResult.errors) {
|
|
55
|
+
this.log(import_tinyrainbow.default.red(` \u2192 ${error.message}`));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (test.annotations().length) {
|
|
59
|
+
this.log();
|
|
60
|
+
this.printAnnotations(test, "log", 3);
|
|
61
|
+
this.log();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
logEvalTestCase(test, avgScore) {
|
|
65
|
+
const colorFn = avgScore < 0.5 ? import_tinyrainbow.default.red : avgScore < 0.75 ? import_tinyrainbow.default.yellow : import_tinyrainbow.default.green;
|
|
66
|
+
let title = ` ${this.getEntityPrefix(test)} `;
|
|
67
|
+
title += test.module.task.name;
|
|
68
|
+
if (test.location) {
|
|
69
|
+
title += import_tinyrainbow.default.dim(`:${test.location.line}:${test.location.column}`);
|
|
70
|
+
}
|
|
71
|
+
title += TEST_NAME_SEPARATOR;
|
|
72
|
+
title += this.getTestName(test.task, TEST_NAME_SEPARATOR);
|
|
73
|
+
title += ` [${colorFn(avgScore.toFixed(2))}]`;
|
|
74
|
+
title += this.getTestCaseSuffix(test);
|
|
75
|
+
this.log(title);
|
|
52
76
|
}
|
|
53
77
|
};
|
|
54
78
|
//# sourceMappingURL=reporter.js.map
|
package/dist/reporter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/reporter.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/reporter.ts"],"sourcesContent":["import { DefaultReporter, VerboseReporter } from \"vitest/node\";\nimport c from \"tinyrainbow\";\n\nconst TEST_NAME_SEPARATOR = c.dim(\" > \");\n\nexport default class DefaultEvalReporter extends VerboseReporter {\n override onTestCaseResult(test: any): void {\n const meta = test.meta();\n if (!meta.eval) {\n super.onTestCaseResult(test);\n return;\n }\n\n // Preserve DefaultReporter's bookkeeping without letting VerboseReporter\n // print the stock per-test line; eval cases need custom score output.\n DefaultReporter.prototype.onTestCaseResult.call(this, test);\n\n const testResult = test.result();\n if (\n this.ctx.config.hideSkippedTests &&\n testResult.state === \"skipped\" &&\n test.options?.mode !== \"todo\"\n ) {\n return;\n }\n\n this.logEvalTestCase(test, meta.eval.avgScore);\n\n if (testResult.state === \"failed\") {\n for (const error of testResult.errors) {\n this.log(c.red(` → ${error.message}`));\n }\n }\n\n if (test.annotations().length) {\n this.log();\n this.printAnnotations(test, \"log\", 3);\n this.log();\n }\n }\n\n private logEvalTestCase(test: any, avgScore: number): void {\n const colorFn =\n avgScore < 0.5 ? c.red : avgScore < 0.75 ? c.yellow : c.green;\n\n let title = ` ${this.getEntityPrefix(test)} `;\n title += test.module.task.name;\n if (test.location) {\n title += c.dim(`:${test.location.line}:${test.location.column}`);\n }\n title += TEST_NAME_SEPARATOR;\n title += this.getTestName(test.task, TEST_NAME_SEPARATOR);\n title += ` [${colorFn(avgScore.toFixed(2))}]`;\n title += this.getTestCaseSuffix(test);\n\n this.log(title);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiD;AACjD,yBAA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,SAAK,IAAI,KAAK;AAAA,EAChB;AACF;","names":["c"]}
|
package/dist/reporter.mjs
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
// src/reporter.ts
|
|
2
|
-
import { DefaultReporter } from "vitest/
|
|
2
|
+
import { DefaultReporter, VerboseReporter } from "vitest/node";
|
|
3
3
|
import c from "tinyrainbow";
|
|
4
|
-
var
|
|
5
|
-
|
|
4
|
+
var TEST_NAME_SEPARATOR = c.dim(" > ");
|
|
5
|
+
var DefaultEvalReporter = class extends VerboseReporter {
|
|
6
|
+
onTestCaseResult(test) {
|
|
7
|
+
var _a;
|
|
6
8
|
const meta = test.meta();
|
|
7
|
-
const testResult = test.result();
|
|
8
9
|
if (!meta.eval) {
|
|
9
|
-
super.
|
|
10
|
+
super.onTestCaseResult(test);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
DefaultReporter.prototype.onTestCaseResult.call(this, test);
|
|
14
|
+
const testResult = test.result();
|
|
15
|
+
if (this.ctx.config.hideSkippedTests && testResult.state === "skipped" && ((_a = test.options) == null ? void 0 : _a.mode) !== "todo") {
|
|
10
16
|
return;
|
|
11
17
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
this.logEvalTestCase(test, meta.eval.avgScore);
|
|
19
|
+
if (testResult.state === "failed") {
|
|
20
|
+
for (const error of testResult.errors) {
|
|
21
|
+
this.log(c.red(` \u2192 ${error.message}`));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (test.annotations().length) {
|
|
25
|
+
this.log();
|
|
26
|
+
this.printAnnotations(test, "log", 3);
|
|
27
|
+
this.log();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
logEvalTestCase(test, avgScore) {
|
|
31
|
+
const colorFn = avgScore < 0.5 ? c.red : avgScore < 0.75 ? c.yellow : c.green;
|
|
32
|
+
let title = ` ${this.getEntityPrefix(test)} `;
|
|
33
|
+
title += test.module.task.name;
|
|
34
|
+
if (test.location) {
|
|
35
|
+
title += c.dim(`:${test.location.line}:${test.location.column}`);
|
|
36
|
+
}
|
|
37
|
+
title += TEST_NAME_SEPARATOR;
|
|
38
|
+
title += this.getTestName(test.task, TEST_NAME_SEPARATOR);
|
|
39
|
+
title += ` [${colorFn(avgScore.toFixed(2))}]`;
|
|
40
|
+
title += this.getTestCaseSuffix(test);
|
|
41
|
+
this.log(title);
|
|
18
42
|
}
|
|
19
43
|
};
|
|
20
44
|
export {
|
package/dist/reporter.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/reporter.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/reporter.ts"],"sourcesContent":["import { DefaultReporter, VerboseReporter } from \"vitest/node\";\nimport c from \"tinyrainbow\";\n\nconst TEST_NAME_SEPARATOR = c.dim(\" > \");\n\nexport default class DefaultEvalReporter extends VerboseReporter {\n override onTestCaseResult(test: any): void {\n const meta = test.meta();\n if (!meta.eval) {\n super.onTestCaseResult(test);\n return;\n }\n\n // Preserve DefaultReporter's bookkeeping without letting VerboseReporter\n // print the stock per-test line; eval cases need custom score output.\n DefaultReporter.prototype.onTestCaseResult.call(this, test);\n\n const testResult = test.result();\n if (\n this.ctx.config.hideSkippedTests &&\n testResult.state === \"skipped\" &&\n test.options?.mode !== \"todo\"\n ) {\n return;\n }\n\n this.logEvalTestCase(test, meta.eval.avgScore);\n\n if (testResult.state === \"failed\") {\n for (const error of testResult.errors) {\n this.log(c.red(` → ${error.message}`));\n }\n }\n\n if (test.annotations().length) {\n this.log();\n this.printAnnotations(test, \"log\", 3);\n this.log();\n }\n }\n\n private logEvalTestCase(test: any, avgScore: number): void {\n const colorFn =\n avgScore < 0.5 ? c.red : avgScore < 0.75 ? c.yellow : c.green;\n\n let title = ` ${this.getEntityPrefix(test)} `;\n title += test.module.task.name;\n if (test.location) {\n title += c.dim(`:${test.location.line}:${test.location.column}`);\n }\n title += TEST_NAME_SEPARATOR;\n title += this.getTestName(test.task, TEST_NAME_SEPARATOR);\n title += ` [${colorFn(avgScore.toFixed(2))}]`;\n title += this.getTestCaseSuffix(test);\n\n this.log(title);\n }\n}\n"],"mappings":";AAAA,SAAS,iBAAiB,uBAAuB;AACjD,OAAO,OAAO;AAEd,IAAM,sBAAsB,EAAE,IAAI,KAAK;AAEvC,IAAqB,sBAArB,cAAiD,gBAAgB;AAAA,EACtD,iBAAiB,MAAiB;AAN7C;AAOI,UAAM,OAAO,KAAK,KAAK;AACvB,QAAI,CAAC,KAAK,MAAM;AACd,YAAM,iBAAiB,IAAI;AAC3B;AAAA,IACF;AAIA,oBAAgB,UAAU,iBAAiB,KAAK,MAAM,IAAI;AAE1D,UAAM,aAAa,KAAK,OAAO;AAC/B,QACE,KAAK,IAAI,OAAO,oBAChB,WAAW,UAAU,eACrB,UAAK,YAAL,mBAAc,UAAS,QACvB;AACA;AAAA,IACF;AAEA,SAAK,gBAAgB,MAAM,KAAK,KAAK,QAAQ;AAE7C,QAAI,WAAW,UAAU,UAAU;AACjC,iBAAW,SAAS,WAAW,QAAQ;AACrC,aAAK,IAAI,EAAE,IAAI,aAAQ,MAAM,OAAO,EAAE,CAAC;AAAA,MACzC;AAAA,IACF;AAEA,QAAI,KAAK,YAAY,EAAE,QAAQ;AAC7B,WAAK,IAAI;AACT,WAAK,iBAAiB,MAAM,OAAO,CAAC;AACpC,WAAK,IAAI;AAAA,IACX;AAAA,EACF;AAAA,EAEQ,gBAAgB,MAAW,UAAwB;AACzD,UAAM,UACJ,WAAW,MAAM,EAAE,MAAM,WAAW,OAAO,EAAE,SAAS,EAAE;AAE1D,QAAI,QAAQ,IAAI,KAAK,gBAAgB,IAAI,CAAC;AAC1C,aAAS,KAAK,OAAO,KAAK;AAC1B,QAAI,KAAK,UAAU;AACjB,eAAS,EAAE,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,MAAM,EAAE;AAAA,IACjE;AACA,aAAS;AACT,aAAS,KAAK,YAAY,KAAK,MAAM,mBAAmB;AACxD,aAAS,KAAK,QAAQ,SAAS,QAAQ,CAAC,CAAC,CAAC;AAC1C,aAAS,KAAK,kBAAkB,IAAI;AAEpC,SAAK,IAAI,KAAK;AAAA,EAChB;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-evals",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"homepage": "https://github.com/getsentry/vitest-evals#readme",
|
|
48
48
|
"description": "",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"zod": "
|
|
50
|
+
"ai": ">=4 <7",
|
|
51
|
+
"tinyrainbow": ">=2 <4",
|
|
52
|
+
"vitest": ">=4 <5",
|
|
53
|
+
"zod": ">=3 <5"
|
|
54
54
|
},
|
|
55
55
|
"peerDependenciesMeta": {
|
|
56
56
|
"ai": {
|
|
@@ -61,20 +61,21 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@ai-sdk/openai": "^
|
|
64
|
+
"@ai-sdk/openai": "^3.0.48",
|
|
65
65
|
"@biomejs/biome": "^1.9.4",
|
|
66
|
-
"@
|
|
67
|
-
"
|
|
68
|
-
"
|
|
66
|
+
"@types/node": "^25.5.0",
|
|
67
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
68
|
+
"ai": "^6.0.141",
|
|
69
|
+
"autoevals": "^0.0.132",
|
|
69
70
|
"dotenv-cli": "^8.0.0",
|
|
70
71
|
"lint-staged": "^15.5.2",
|
|
71
|
-
"openai": "^
|
|
72
|
+
"openai": "^6.33.0",
|
|
72
73
|
"simple-git-hooks": "^2.13.0",
|
|
73
|
-
"tinyrainbow": "^
|
|
74
|
+
"tinyrainbow": "^3.1.0",
|
|
74
75
|
"tsup": "^8.5.0",
|
|
75
76
|
"typescript": "^5.8.3",
|
|
76
|
-
"vitest": "^
|
|
77
|
-
"zod": "^3.
|
|
77
|
+
"vitest": "^4.1.2",
|
|
78
|
+
"zod": "^4.3.6"
|
|
78
79
|
},
|
|
79
80
|
"simple-git-hooks": {
|
|
80
81
|
"pre-commit": "npm exec lint-staged --concurrent false"
|