Running tests
Run all tests
Run specific tests
You can target specific test files or packages:The
@ suffix is required in test target names. It indicates the default test variant.Test types
.wd-test files
Cap’n Proto config files that define test workers with embedded JavaScript/TypeScript modules.Example test
modules- Embed JS/TS test filescompatibilityFlags- Enable featuresbindings- Service bindings, KV, JSON, etc.durableObjectNamespaces- Durable Object configuration
C++ tests
KJ-based unit tests using thekj_test() macro:
Node.js compatibility tests
Test Node.js API compatibility:Web Platform Tests
Run WPT (Web Platform Tests):Test variants
Every test automatically generates three variants:| Variant | Description |
|---|---|
name@ | Default variant with oldest compatibility date (2000-01-01) |
name@all-compat-flags | Newest compatibility date (2999-12-31), all flags enabled |
name@all-autogates | All autogates enabled with oldest compatibility date |
Creating new tests
Create a .wd-test
Create a WPT test
Running tests with sanitizers
AddressSanitizer (ASAN)
Detect memory errors:Code coverage
Finding test targets
To find the right target name for a file:- Check the
BUILD.bazelfile in the same directory forwd_test()orkj_test()rules - Use Bazel query:
Benchmarking
Run performance benchmarks:Continuous testing
Watch for changes and rerun tests automatically:Next steps
Debugging
Learn to debug failing tests
Building
Build workerd from source