Vitest integration
The Vitest integration allows you to run LangSmith evaluations using familiar Vitest syntax.Installation
Basic usage
Usels.test() and ls.describe() to define evaluation test cases:
Testing multiple examples
Usels.test.each() to iterate over multiple test cases:
Custom evaluators
Wrap evaluator functions withls.wrapEvaluator():
Logging feedback
Usels.logFeedback() to add scores to your experiments:
Running tests
Run your tests with Vitest:LANGSMITH_TEST_TRACKING=false to disable LangSmith tracking for local-only testing:
Jest integration
Jest integration is similar to Vitest but uses Jest’s testing primitives.Installation
Basic usage
.each(), logFeedback(), wrapEvaluator()) work identically in Jest.
Pytest integration
The Pytest plugin enables LangSmith evaluations within Python test suites.Installation
Configuration
Add the LangSmith plugin topytest.ini or pyproject.toml:
Basic usage
Use the@pytest.mark.langsmith decorator:
Parametrized tests
Use@pytest.mark.parametrize for multiple examples:
Using fixtures
LangSmith works with pytest fixtures:Logging inputs and reference outputs
Running tests
Run pytest normally:Disabling test tracking
To run tests locally without creating experiments in LangSmith:Best practices
ls.describe("Customer support QA", () => {
// All tests here belong to the "Customer support QA" dataset
});
ls.test(
"Test case",
{
inputs: { query: "..." },
referenceOutputs: { answer: "..." } // Include expected outputs
},
async ({ inputs, referenceOutputs }) => {
// ...
}
);
ls.logFeedback({ key: "correctness", score: 1.0 });
ls.logFeedback({ key: "latency_ms", score: 150 });
ls.logFeedback({ key: "user_satisfaction", score: 0.85 });