skills/noise/testing_patterns/SKILL.md
Unit testing and integration testing best practices
npx skillsauth add langchain-ai/skills-benchmarks testing-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Write effective, maintainable tests using modern patterns.
def test_user_registration():
# Arrange
user_data = {"email": "[email protected]", "password": "secure123"}
# Act
result = register_user(user_data)
# Assert
assert result.success is True
assert result.user.email == "[email protected]"
from unittest.mock import Mock, patch
@patch('services.email.send_email')
def test_sends_welcome_email(mock_send):
mock_send.return_value = True
register_user({"email": "[email protected]"})
mock_send.assert_called_once_with(
to="[email protected]",
template="welcome"
)
import pytest
from factories import UserFactory
@pytest.fixture
def user():
return UserFactory.create(role="admin")
@pytest.fixture
def authenticated_client(user):
client = TestClient(app)
client.login(user)
return client
def test_admin_dashboard(authenticated_client):
response = authenticated_client.get("/admin")
assert response.status_code == 200
@pytest.mark.integration
def test_full_checkout_flow(db_session, stripe_mock):
# Create test data
user = create_user()
product = create_product(price=100)
# Execute flow
cart = add_to_cart(user, product)
order = checkout(cart, payment_method="card")
# Verify
assert order.status == "completed"
assert stripe_mock.charges.create.called
development
INVOKE FIRST for any LangChain / LangGraph / Deep Agents agent building project before consulting other skills or writing any agent code. Required starting point for up to date info on framework selection (LangChain vs LangGraph vs Deep Agents vs hybrid composition), agent patterns, install, environment setup, and which skill to load next.
tools
INVOKE THIS SKILL when working with LangSmith tracing OR querying traces. Covers adding tracing to applications and querying/exporting trace data. Uses the langsmith CLI tool.
tools
INVOKE THIS SKILL when building evaluation pipelines for LangSmith. Covers three core components: (1) Creating Evaluators - LLM-as-Judge, custom code; (2) Defining Run Functions - how to capture outputs and trajectories from your agent; (3) Running Evaluations - locally with evaluate() or auto-run via LangSmith. Uses the langsmith CLI tool.
development
Modern React component patterns with hooks and TypeScript