Skip to content

Commit 8fd928f

Browse files
authored
Assert exact classifier input and answer shape
1 parent 9ee3470 commit 8fd928f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎dev-packages/e2e-tests/test-applications/node-mastra/tests/classifier.test.ts‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ test('captures a Mastra classifier (Jev) evaluation as a gen_ai.evaluate span',
5151
expect(attrValue(evaluateSpan, GEN_AI_REQUEST_MODEL)).toBe('typesafe/jev-1.13');
5252
expect(attrValue(evaluateSpan, GEN_AI_PROVIDER_NAME)).toBe('openrouter');
5353
expect(attrValue(evaluateSpan, GEN_AI_USAGE_INPUT_TOKENS)).toBeGreaterThan(0);
54-
expect(String(attrValue(evaluateSpan, GEN_AI_INPUT_MESSAGES))).toContain(TICKET);
55-
expect(String(attrValue(evaluateSpan, GEN_AI_OUTPUT_MESSAGES))).toContain('"is_bug"');
54+
expect(JSON.parse(String(attrValue(evaluateSpan, GEN_AI_INPUT_MESSAGES)))).toEqual([
55+
{
56+
type: 'evaluation',
57+
state: { ticket: TICKET },
58+
questions: {
59+
is_bug: { type: 'boolean', instructions: 'Is the customer reporting a software defect?' },
60+
},
61+
},
62+
]);
63+
// The probability comes from the live model, so only its shape is stable.
64+
expect(JSON.parse(String(attrValue(evaluateSpan, GEN_AI_OUTPUT_MESSAGES)))).toEqual([
65+
{ type: 'evaluation', answers: { is_bug: { type: 'boolean', probability: expect.any(Number) } } },
66+
]);
5667
});

0 commit comments

Comments
 (0)