langsmith 0.3.81 → 0.3.82

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,12 +1,31 @@
1
1
  /* eslint-disable import/no-extraneous-dependencies */
2
- import { printVitestReporterTable } from "./utils/reporter.js";
2
+ import { printVitestReporterTable, printVitestTestModulesReporterTable, } from "./utils/reporter.js";
3
3
  import { importVitestModule } from "./utils/esm.mjs";
4
4
  const vitestReporters = await importVitestModule("reporters");
5
5
  const DefaultReporter = vitestReporters.DefaultReporter;
6
6
  class LangSmithEvalReporter extends DefaultReporter {
7
+ constructor() {
8
+ super(...arguments);
9
+ Object.defineProperty(this, "skipOnFinished", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: false
14
+ });
15
+ }
7
16
  async onFinished(files, errors) {
8
17
  super.onFinished(files, errors);
18
+ // Vitest 3.x will call `onFinished` after `onTestRunEnd`,
19
+ // thus we need to gate this to avoid double printing.
20
+ if (this.skipOnFinished)
21
+ return;
9
22
  await printVitestReporterTable(files, this.ctx);
10
23
  }
24
+ // `onFinished` is removed in Vitest 4.x, so we use `onTestRunEnd` instead.
25
+ async onTestRunEnd(testModules, unhandledErrors, reason) {
26
+ super.onTestRunEnd(testModules, unhandledErrors, reason);
27
+ this.skipOnFinished = true;
28
+ await printVitestTestModulesReporterTable(testModules);
29
+ }
11
30
  }
12
31
  export default LangSmithEvalReporter;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printVitestReporterTable = void 0;
3
+ exports.printVitestTestModulesReporterTable = exports.printVitestReporterTable = void 0;
4
4
  const reporter_js_1 = require("../../utils/jestlike/reporter.cjs");
5
5
  // Can't use types here because of module resolution issues
6
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -23,3 +23,16 @@ const printVitestReporterTable = async (files, ctx) => {
23
23
  }
24
24
  };
25
25
  exports.printVitestReporterTable = printVitestReporterTable;
26
+ const printVitestTestModulesReporterTable = async (testModules) => {
27
+ for (const testModule of testModules) {
28
+ const tests = [...testModule.children.allTests()].map((test) => {
29
+ return {
30
+ title: test.name,
31
+ status: test.result()?.state ?? "skipped",
32
+ duration: Math.round(test.diagnostic()?.duration ?? 0),
33
+ };
34
+ });
35
+ await (0, reporter_js_1.printReporterTable)(testModule.relativeModuleId, tests, testModule.state());
36
+ }
37
+ };
38
+ exports.printVitestTestModulesReporterTable = printVitestTestModulesReporterTable;
@@ -1 +1,31 @@
1
1
  export declare const printVitestReporterTable: (files: any, ctx: any) => Promise<void>;
2
+ export interface VitestTestModule {
3
+ children: {
4
+ allTests: () => {
5
+ name: string;
6
+ result: () => {
7
+ state: "pending" | "passed" | "failed" | "skipped";
8
+ };
9
+ diagnostic: () => {
10
+ duration: number;
11
+ };
12
+ }[];
13
+ };
14
+ state: () => "skipped" | "passed" | "failed";
15
+ relativeModuleId: string;
16
+ }
17
+ export declare const printVitestTestModulesReporterTable: (testModules: {
18
+ children: {
19
+ allTests: () => {
20
+ name: string;
21
+ result: () => {
22
+ state: "pending" | "passed" | "failed" | "skipped";
23
+ };
24
+ diagnostic: () => {
25
+ duration: number;
26
+ };
27
+ }[];
28
+ };
29
+ state: () => "skipped" | "passed" | "failed";
30
+ relativeModuleId: string;
31
+ }[]) => Promise<void>;
@@ -19,3 +19,15 @@ export const printVitestReporterTable = async (files, ctx) => {
19
19
  }
20
20
  }
21
21
  };
22
+ export const printVitestTestModulesReporterTable = async (testModules) => {
23
+ for (const testModule of testModules) {
24
+ const tests = [...testModule.children.allTests()].map((test) => {
25
+ return {
26
+ title: test.name,
27
+ status: test.result()?.state ?? "skipped",
28
+ duration: Math.round(test.diagnostic()?.duration ?? 0),
29
+ };
30
+ });
31
+ await printReporterTable(testModule.relativeModuleId, tests, testModule.state());
32
+ }
33
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.3.81",
3
+ "version": "0.3.82",
4
4
  "description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
5
5
  "packageManager": "yarn@1.22.19",
6
6
  "files": [
@@ -144,7 +144,6 @@
144
144
  "chalk": "^4.1.2",
145
145
  "console-table-printer": "^2.12.1",
146
146
  "p-queue": "^6.6.2",
147
- "p-retry": "4",
148
147
  "semver": "^7.6.3",
149
148
  "uuid": "^10.0.0"
150
149
  },