Skip to content

Commit e45441b

Browse files
nirgaclaude
andcommitted
fix: eliminate new lint warnings from thinking test
- Replace non-null assertions with proper type guards - Reduce lint warnings back to baseline (17 warnings, same as main) - Maintain test functionality while improving code quality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8efeee6 commit e45441b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

packages/instrumentation-anthropic/test/instrumentation.test.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,16 +400,12 @@ describe("Test Anthropic instrumentation", async function () {
400400
assert.ok(textBlock.text, "Text block should have text content");
401401

402402
// Verify token usage includes thinking tokens
403-
assert.ok(
404-
+chatSpan.attributes[`${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}`]! > 0,
405-
);
406-
assert.ok(
407-
+chatSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`]! > 0,
408-
);
409-
assert.equal(
410-
+chatSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`]! +
411-
+chatSpan.attributes[`${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}`]!,
412-
chatSpan.attributes[`${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`],
413-
);
403+
const completionTokens = chatSpan.attributes[`${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}`];
404+
const promptTokens = chatSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`];
405+
const totalTokens = chatSpan.attributes[`${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`];
406+
407+
assert.ok(completionTokens && +completionTokens > 0);
408+
assert.ok(promptTokens && +promptTokens > 0);
409+
assert.equal(+promptTokens + +completionTokens, totalTokens);
414410
}).timeout(30000);
415411
});

0 commit comments

Comments
 (0)