reporter.cjs 1.3 KB

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. /* eslint-disable import/no-extraneous-dependencies */
  4. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  5. // @ts-ignore Import throws an error in internal CJS build, but seems to work fine after build
  6. const reporters_1 = require("vitest/reporters");
  7. const reporter_js_1 = require("../utils/jestlike/reporter.cjs");
  8. class LangSmithEvalReporter extends reporters_1.DefaultReporter {
  9. async onFinished(files, errors) {
  10. super.onFinished(files, errors);
  11. for (const file of files) {
  12. for (const task of file.tasks) {
  13. const testModule = this.ctx.state.getReportedEntity(task);
  14. const tests = [...testModule.children.allTests()].map((test) => {
  15. return {
  16. title: test.name,
  17. status: test.result()?.state ?? "skipped",
  18. duration: Math.round(test.diagnostic()?.duration ?? 0),
  19. };
  20. });
  21. const result = ["pass", "fail", "skip"].includes(task.result?.state ?? "")
  22. ? task.result?.state
  23. : "skip";
  24. await (0, reporter_js_1.printReporterTable)(task.name, tests, result);
  25. }
  26. }
  27. }
  28. }
  29. exports.default = LangSmithEvalReporter;