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.
@@ -1,7 +1,8 @@
1
- import { DefaultReporter } from 'vitest/reporters';
1
+ import { VerboseReporter } from 'vitest/node';
2
2
 
3
- declare class DefaultEvalReporter extends DefaultReporter {
4
- protected printTestCase(moduleState: any, test: any): void;
3
+ declare class DefaultEvalReporter extends VerboseReporter {
4
+ onTestCaseResult(test: any): void;
5
+ private logEvalTestCase;
5
6
  }
6
7
 
7
8
  export { DefaultEvalReporter as default };
@@ -1,7 +1,8 @@
1
- import { DefaultReporter } from 'vitest/reporters';
1
+ import { VerboseReporter } from 'vitest/node';
2
2
 
3
- declare class DefaultEvalReporter extends DefaultReporter {
4
- protected printTestCase(moduleState: any, test: any): void;
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 import_reporters = require("vitest/reporters");
36
+ var import_node = require("vitest/node");
37
37
  var import_tinyrainbow = __toESM(require("tinyrainbow"));
38
- var DefaultEvalReporter = class extends import_reporters.DefaultReporter {
39
- printTestCase(moduleState, test) {
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.printTestCase(moduleState, test);
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
- const padding = this.getTestIndentation(test.task);
47
- const icon = testResult.state === "failed" ? import_tinyrainbow.default.red("\u2717 ") : " ";
48
- const colorFn = meta.eval.avgScore < 0.5 ? import_tinyrainbow.default.red : meta.eval.avgScore < 0.75 ? import_tinyrainbow.default.yellow : import_tinyrainbow.default.green;
49
- this.log(
50
- `${padding}${icon}${this.getTestName(test.task, import_tinyrainbow.default.dim(" > "))} [${colorFn(meta.eval.avgScore.toFixed(2))}]`
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
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/reporter.ts"],"sourcesContent":["// import type { RunnerTask, RunnerTestFile } from \"vitest\";\nimport { DefaultReporter } from \"vitest/reporters\";\nimport c from \"tinyrainbow\";\n\nexport default class DefaultEvalReporter extends DefaultReporter {\n protected override printTestCase(moduleState: any, test: any): void {\n const meta = test.meta();\n const testResult = test.result();\n\n if (!meta.eval) {\n super.printTestCase(moduleState, test);\n return;\n }\n\n const padding = this.getTestIndentation(test.task);\n const icon = testResult.state === \"failed\" ? c.red(\"✗ \") : \" \";\n const colorFn =\n meta.eval.avgScore < 0.5\n ? c.red\n : meta.eval.avgScore < 0.75\n ? c.yellow\n : c.green;\n this.log(\n `${padding}${icon}${this.getTestName(test.task, c.dim(\" > \"))} [${colorFn(meta.eval.avgScore.toFixed(2))}]`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAgC;AAChC,yBAAc;AAEd,IAAqB,sBAArB,cAAiD,iCAAgB;AAAA,EAC5C,cAAc,aAAkB,MAAiB;AAClE,UAAM,OAAO,KAAK,KAAK;AACvB,UAAM,aAAa,KAAK,OAAO;AAE/B,QAAI,CAAC,KAAK,MAAM;AACd,YAAM,cAAc,aAAa,IAAI;AACrC;AAAA,IACF;AAEA,UAAM,UAAU,KAAK,mBAAmB,KAAK,IAAI;AACjD,UAAM,OAAO,WAAW,UAAU,WAAW,mBAAAA,QAAE,IAAI,SAAI,IAAI;AAC3D,UAAM,UACJ,KAAK,KAAK,WAAW,MACjB,mBAAAA,QAAE,MACF,KAAK,KAAK,WAAW,OACnB,mBAAAA,QAAE,SACF,mBAAAA,QAAE;AACV,SAAK;AAAA,MACH,GAAG,OAAO,GAAG,IAAI,GAAG,KAAK,YAAY,KAAK,MAAM,mBAAAA,QAAE,IAAI,KAAK,CAAC,CAAC,KAAK,QAAQ,KAAK,KAAK,SAAS,QAAQ,CAAC,CAAC,CAAC;AAAA,IAC1G;AAAA,EACF;AACF;","names":["c"]}
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,yBAAc;AAEd,IAAM,sBAAsB,mBAAAA,QAAE,IAAI,KAAK;AAEvC,IAAqB,sBAArB,cAAiD,4BAAgB;AAAA,EACtD,iBAAiB,MAAiB;AAN7C;AAOI,UAAM,OAAO,KAAK,KAAK;AACvB,QAAI,CAAC,KAAK,MAAM;AACd,YAAM,iBAAiB,IAAI;AAC3B;AAAA,IACF;AAIA,gCAAgB,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,mBAAAA,QAAE,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,mBAAAA,QAAE,MAAM,WAAW,OAAO,mBAAAA,QAAE,SAAS,mBAAAA,QAAE;AAE1D,QAAI,QAAQ,IAAI,KAAK,gBAAgB,IAAI,CAAC;AAC1C,aAAS,KAAK,OAAO,KAAK;AAC1B,QAAI,KAAK,UAAU;AACjB,eAAS,mBAAAA,QAAE,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":["c"]}
package/dist/reporter.mjs CHANGED
@@ -1,20 +1,44 @@
1
1
  // src/reporter.ts
2
- import { DefaultReporter } from "vitest/reporters";
2
+ import { DefaultReporter, VerboseReporter } from "vitest/node";
3
3
  import c from "tinyrainbow";
4
- var DefaultEvalReporter = class extends DefaultReporter {
5
- printTestCase(moduleState, test) {
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.printTestCase(moduleState, test);
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
- const padding = this.getTestIndentation(test.task);
13
- const icon = testResult.state === "failed" ? c.red("\u2717 ") : " ";
14
- const colorFn = meta.eval.avgScore < 0.5 ? c.red : meta.eval.avgScore < 0.75 ? c.yellow : c.green;
15
- this.log(
16
- `${padding}${icon}${this.getTestName(test.task, c.dim(" > "))} [${colorFn(meta.eval.avgScore.toFixed(2))}]`
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 {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/reporter.ts"],"sourcesContent":["// import type { RunnerTask, RunnerTestFile } from \"vitest\";\nimport { DefaultReporter } from \"vitest/reporters\";\nimport c from \"tinyrainbow\";\n\nexport default class DefaultEvalReporter extends DefaultReporter {\n protected override printTestCase(moduleState: any, test: any): void {\n const meta = test.meta();\n const testResult = test.result();\n\n if (!meta.eval) {\n super.printTestCase(moduleState, test);\n return;\n }\n\n const padding = this.getTestIndentation(test.task);\n const icon = testResult.state === \"failed\" ? c.red(\"✗ \") : \" \";\n const colorFn =\n meta.eval.avgScore < 0.5\n ? c.red\n : meta.eval.avgScore < 0.75\n ? c.yellow\n : c.green;\n this.log(\n `${padding}${icon}${this.getTestName(test.task, c.dim(\" > \"))} [${colorFn(meta.eval.avgScore.toFixed(2))}]`,\n );\n }\n}\n"],"mappings":";AACA,SAAS,uBAAuB;AAChC,OAAO,OAAO;AAEd,IAAqB,sBAArB,cAAiD,gBAAgB;AAAA,EAC5C,cAAc,aAAkB,MAAiB;AAClE,UAAM,OAAO,KAAK,KAAK;AACvB,UAAM,aAAa,KAAK,OAAO;AAE/B,QAAI,CAAC,KAAK,MAAM;AACd,YAAM,cAAc,aAAa,IAAI;AACrC;AAAA,IACF;AAEA,UAAM,UAAU,KAAK,mBAAmB,KAAK,IAAI;AACjD,UAAM,OAAO,WAAW,UAAU,WAAW,EAAE,IAAI,SAAI,IAAI;AAC3D,UAAM,UACJ,KAAK,KAAK,WAAW,MACjB,EAAE,MACF,KAAK,KAAK,WAAW,OACnB,EAAE,SACF,EAAE;AACV,SAAK;AAAA,MACH,GAAG,OAAO,GAAG,IAAI,GAAG,KAAK,YAAY,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,CAAC,KAAK,QAAQ,KAAK,KAAK,SAAS,QAAQ,CAAC,CAAC,CAAC;AAAA,IAC1G;AAAA,EACF;AACF;","names":[]}
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.6.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
- "tinyrainbow": "*",
51
- "vitest": "*",
52
- "ai": "^4.0.0",
53
- "zod": "^3.0.0"
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": "^1.3.23",
64
+ "@ai-sdk/openai": "^3.0.48",
65
65
  "@biomejs/biome": "^1.9.4",
66
- "@vitest/coverage-v8": "^3.2.4",
67
- "ai": "^4.3.19",
68
- "autoevals": "^0.0.127",
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": "^4.104.0",
72
+ "openai": "^6.33.0",
72
73
  "simple-git-hooks": "^2.13.0",
73
- "tinyrainbow": "^2.0.0",
74
+ "tinyrainbow": "^3.1.0",
74
75
  "tsup": "^8.5.0",
75
76
  "typescript": "^5.8.3",
76
- "vitest": "^3.2.4",
77
- "zod": "^3.25.76"
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"