The Sentry JavaScript SDK has comprehensive test coverage including unit tests, integration tests, and E2E tests. This guide explains how to run them all.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/getsentry/sentry-javascript/llms.txt
Use this file to discover all available pages before exploring further.
You must run
yarn build before yarn test will work, as tests depend on built type definitions.Unit Tests
Run All Unit Tests
From the repository root:Run Tests for a Single Package
Navigate to the package directory and run tests:Run Tests for Changed Packages
To run tests only for packages affected by your changes:Test Configuration
Tests are run with Vitest. Each package has atest script in its package.json:
Integration Tests
Integration tests verify SDK behavior in real runtime environments.Browser Integration Tests
Test browser-specific functionality using Playwright:Node.js Integration Tests
Test Node.js-specific functionality:Cloudflare Integration Tests
Test Cloudflare Workers functionality:E2E Tests
E2E tests verify SDK behavior in real-world framework scenarios using a local npm registry (Verdaccio).Prerequisites
- Docker - Required to run the Verdaccio registry container
- Volta with pnpm support - Enable with
VOLTA_FEATURE_PNPM=1
Setup
- Build packages and create tarballs:
- Configure environment (optional):
Run E2E Tests
Run all E2E tests:How E2E Tests Work
- A fake npm registry (Verdaccio) is launched in Docker
- SDK packages are built, packed, and published to Verdaccio
- Test applications install packages from Verdaccio
- Tests run against the test applications
E2E Test Structure
Test applications live indev-packages/e2e-tests/test-applications/:
Important: The .npmrc File
Every E2E test application must have an.npmrc file:
Testing Locally
To test local SDK versions in external test projects, you have several options:Option 1: yarn link
Symlink your local package:Option 2: yalc
Use yalc to install packages as if they were published:Option 3: Tarballs
Install from a tarball:CI Testing
Browser Tests
Node Tests
Bun Tests
Adding Tests
Any non-trivial fixes/features should include tests. You’ll find atest/ folder in each package.
Unit Tests
Add tests in the package’stest/ directory:
Integration Tests
- Browser changes: Add tests in
dev-packages/browser-integration-tests - Node changes: Add tests in
dev-packages/node-integration-tests - E2E tests: Add test apps in
dev-packages/e2e-tests/test-applications
Common Issues
Tests fail after SDK changes
Rebuild packages:E2E tests use wrong package versions
- Check for
.npmrcfile in test application - Rebuild tarballs:
yarn build && yarn build:tarball - Delete
node_modulesin test app and re-run
Docker/Verdaccio issues
- Ensure Docker daemon is running
- Check port 4873 is not in use:
lsof -i :4873 - Stop existing containers:
docker ps && docker stop <container-id>
Type errors in tests
Ensure types are built:Debugging Tests
- Enable debug mode: Add
debug: trueto Sentry config - Check browser console: Look for SDK initialization errors
- Inspect network requests: Verify events are sent correctly
- Check installed versions: Verify package versions in
node_modules
Next Steps
- Learn about the development workflow
- Understand the monorepo architecture
- Read about commit and PR guidelines