write-tests
Write Tests
Tests are not production code. They are documentation — each one is a tiny executable spec that says "this system does X." A reader should grasp the intent in seconds. A failure should point to exactly one broken behavior, not leave you going through a 40-line test body.
Workflow
Follow these steps in order before writing any test code.
-
Decide the framework. Testing a function's return value, side effects, or module interactions → Vitest (lives under
packages/<name>/test/). Testing that a real HTTP request to a running app produces the correct Sentry envelope → Playwright (lives underdev-packages/e2e-tests/test-applications/<app>/tests/). -
Read 2–3 existing test files in the target
test/directory. Specifically note:- Which
vi.mockstyle they use (string path or import form) - What cleanup they do in
beforeEach(clearAllMocksvsrestoreAllMocks) - How they import the module under test (
../../src/...vs@sentry/...)
- Which
More from getsentry/sentry-javascript
fix-security-vulnerability
Analyze and propose fixes for Dependabot security alerts
12skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
11triage-issue
Triage GitHub issues with codebase research and actionable recommendations
10e2e
Run E2E tests for Sentry JavaScript SDK test applications
9release
Publish a new Sentry JavaScript SDK release. Use when preparing a release, updating the changelog, or creating a release branch.
9dotagents
Manage agent skill dependencies with dotagents. Use when asked to "add a skill", "install skills", "remove a skill", "update skills", "dotagents init", "agents.toml", "agents.lock", "sync skills", "list skills", "set up dotagents", "configure trust", "add MCP server", "add hook", "wildcard skills", "user scope", or any dotagents-related task.
9