Skip to content

Conversation

christian-bromann
Copy link
Member

Migrating @langchain/anthropic to Vitest.

Copy link

vercel bot commented Aug 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Project Deployment Preview Comments Updated (UTC)
langchainjs-docs Ready Preview 💬 Add feedback Aug 12, 2025 0:58am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored Aug 12, 2025 0:58am

Comment on lines -48 to +46
test("ChatAnthropicStandardIntegrationTests", async () => {
const testResults = await testClass.runTests();
expect(testResults).toBe(true);
});
testClass.runTests("ChatAnthropicStandardIntegrationTests");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standard tests doesn't enclose test suites inside of a test block, so I'm pretty sure this will cause false positives

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standard tests doesn't enclose test suites inside of a test block, so I'm pretty sure this will cause false positives

@hntrl the Vitest export of this package does see

/**
* Run all unit tests for the chat model.
* Each test is wrapped in a try/catch block to prevent the entire test suite from failing.
* If a test fails, the error is logged to the console, and the test suite continues.
* @returns {boolean}
*/
runTests(testName = "ChatModelUnitTests") {
describe(testName, () => {
test("should initialize chat model successfully", () =>
this.testChatModelInit());
test("should initialize chat model with API key", () =>
this.testChatModelInitApiKey());
test("should initialize chat model with streaming enabled", () =>
this.testChatModelInitStreaming());
test("should bind tools when tool calling is supported", () =>
this.testChatModelWithBindTools());
test("should work with structured output when supported", () =>
this.testChatModelWithStructuredOutput());
test("should return standard LangSmith parameters", () =>
this.testStandardParams());
});
}

The reason for this is that previous behavior would log an error but would throw away stack traces and diffs.

Comment on lines -36 to +34
test("ChatAnthropicStandardUnitTests", () => {
const testResults = testClass.runTests();
expect(testResults).toBe(true);
});
testClass.runTests("ChatAnthropicStandardUnitTests");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@christian-bromann christian-bromann merged commit 43ff6f4 into v1 Aug 12, 2025
107 checks passed
@christian-bromann christian-bromann deleted the cb/migrate-anthropic-to-vitest branch August 12, 2025 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants