Skip to content

Commit 20cc074

Browse files
authored
fix(js): Separate Jest suites into separate tables when reporting (#1443)
1 parent 54a7a3c commit 20cc074

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "langsmith",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
55
"packageManager": "yarn@1.22.19",
66
"files": [

js/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ export { RunTree, type RunTreeConfig } from "./run_trees.js";
1818
export { overrideFetchImplementation } from "./singletons/fetch.js";
1919

2020
// Update using yarn bump-version
21-
export const __version__ = "0.3.1";
21+
export const __version__ = "0.3.2";

js/src/jest/reporter.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@ import { printReporterTable } from "../utils/jestlike/reporter.js";
55

66
class LangSmithEvalReporter extends DefaultReporter {
77
async onTestResult(test: any, testResult: any, aggregatedResults: any) {
8+
const groupedTestResults = testResult.testResults.reduce(
9+
(groups: Record<string, any>, testResult: any) => {
10+
const ancestorTitle = testResult.ancestorTitles.join(" > ");
11+
if (groups[ancestorTitle] === undefined) {
12+
groups[ancestorTitle] = [];
13+
}
14+
groups[ancestorTitle].push(testResult);
15+
return groups;
16+
},
17+
{}
18+
);
819
try {
9-
await printReporterTable(
10-
testResult.testResults,
11-
testResult.failureMessage
12-
);
20+
for (const testGroupName of Object.keys(groupedTestResults)) {
21+
const resultGroup = groupedTestResults[testGroupName];
22+
await printReporterTable(resultGroup, testResult.failureMessage);
23+
}
1324
} catch (e: any) {
1425
console.log("Failed to display LangSmith eval results:", e.message);
1526
super.onTestResult(test, testResult, aggregatedResults);

js/src/tests/jestlike/jest.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ const scoreMarketingCopyAgent = async () => {
192192
};
193193
};
194194

195-
ls.describe.only("Test Tweet", () => {
195+
ls.describe("Test Tweet", () => {
196196
ls.test(
197197
"should generate a tweet LS",
198198
{

js/src/utils/jestlike/reporter.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ScoreType } from "../../schemas.js";
99
import { STRIP_ANSI_REGEX, TEST_ID_DELIMITER } from "./index.js";
1010

1111
const FEEDBACK_COLLAPSE_THRESHOLD = 48;
12+
const MAX_TEST_PARAMS_LENGTH = 18;
1213

1314
const RESERVED_KEYS = [
1415
"Name",
@@ -60,7 +61,9 @@ function formatValue(value: unknown) {
6061
const rawValue = typeof v === "string" ? v : JSON.stringify(v);
6162
const rawEntry = `${k}: ${rawValue}`;
6263
const entry =
63-
rawEntry.length > 24 ? rawEntry.slice(0, 21) + "..." : rawEntry;
64+
rawEntry.length > MAX_TEST_PARAMS_LENGTH
65+
? rawEntry.slice(0, MAX_TEST_PARAMS_LENGTH - 3) + "..."
66+
: rawEntry;
6467
return entry;
6568
})
6669
.join("\n");
@@ -223,9 +226,13 @@ export async function printReporterTable(
223226
minLen?: number;
224227
}[] = [
225228
{ name: "Test", alignment: "left", maxLen: 36 },
226-
{ name: "Inputs", alignment: "left", minLen: 24 },
227-
{ name: "Reference Outputs", alignment: "left", minLen: 24 },
228-
{ name: "Outputs", alignment: "left", minLen: 24 },
229+
{ name: "Inputs", alignment: "left", minLen: MAX_TEST_PARAMS_LENGTH },
230+
{
231+
name: "Reference Outputs",
232+
alignment: "left",
233+
minLen: MAX_TEST_PARAMS_LENGTH,
234+
},
235+
{ name: "Outputs", alignment: "left", minLen: MAX_TEST_PARAMS_LENGTH },
229236
{ name: "Status", alignment: "left" },
230237
];
231238
if (collapseFeedbackColumn) {
@@ -245,7 +252,7 @@ export async function printReporterTable(
245252
defaultColumns.push({
246253
name: "Feedback",
247254
alignment: "left",
248-
minLen: feedbackColumnLength + 10,
255+
minLen: feedbackColumnLength + 8,
249256
});
250257
}
251258
console.log();

0 commit comments

Comments
 (0)