本页还没有译文
本页 27 段还没译成한국어,下面显示的是英文原文。Using standard tests
还没翻译译自英文(docs.langchain.com)本页 27 段都还没译
Standard tests ensure your integration works as expected.
When creating either a custom class for yourself or to publish in a LangChain integration, it is necessary to add tests to ensure it works as expected. LangChain provides a comprehensive set of tests for each integration type for you. This guide will show you how to add LangChain's standard test suite to each integration type.
Setup
First, install the required dependencies:
Defines the interfaces we want to import to define our custom components
Provides the standard tests and plugins necessary to run them
npm install @langchain/core
npm install @langchain/standard-testspnpm add @langchain/core
pnpm add @langchain/standard-testsyarn add @langchain/core
yarn add @langchain/standard-testsbun add @langchain/core
bun add @langchain/standard-testsThere are 2 namespaces in the langchain-tests package:
Unit tests
Location: src.unit_tests
Designed to test the component in isolation and without access to external services
Integration tests
Location: src.integration_tests
Designed to test the component with access to external services (in particular, the external service that the component is designed to interact with)
Implementing standard tests
Depending on your integration type, you will need to implement either or both unit and integration tests.
By subclassing the standard test suite for your integration type, you get the full collection of standard tests for that type. For a test run to be successful, a given test should pass only if the model supports the capability being tested. Otherwise, the test should be skipped.
Because different integrations offer unique sets of features, most standard tests provided by LangChain are opt-in by default to prevent false positives. Consequently, you will need to override properties to indicate which features your integration supports - see the below example for an illustration.
// Indicate that a chat model supports parallel tool calls
class ChatParrotLinkStandardIntegrationTests extends ChatModelIntegrationTests<
ChatParrotLinkCallOptions,
AIMessageChunk
> {
constructor() {
// ... other required properties
super({
// ... other required properties
supportsParallelToolCalls: true, // (The default is False)
// ...
});
}Note
You should organize tests in these subdirectories relative to the root of your package:
tests/unit_testsfor unit teststests/integration_testsfor integration tests
To see the complete list of configurable capabilities and their defaults, see Implementing standard tests.
Sandbox integrations
Deep Agents sandbox integrations use sandboxStandardTests from @langchain/sandbox-standard-tests.
Call it with a config object that includes createSandbox, resolvePath, and closeSandbox.
Use the Daytona integration tests as a reference implementation.
See Contributing a sandbox integration for publishing guidelines.
Troubleshooting
For a full list of the standard test suites that are available, as well as information on which tests are included and how to troubleshoot common issues, see the contributing README.