Quick Development Commands
Building and Running
Code Quality
Testing
Running Tests
Test Organization
Deno uses several types of tests:Spec Tests
Location:
tests/specs/Main integration tests that execute CLI commands and validate output.Unit Tests
Location: Inline with source codeTest individual functions and modules.
Integration Tests
Location:
cli/tests/Additional integration tests for CLI functionality.Web Platform Tests
Location:
tests/wpt/Tests for web standards compliance.Spec Tests
The main form of integration test in Deno is the “spec” test. These tests execute CLI commands and assert against their output.Creating a Spec Test
Add test configuration
Create
__test__.jsonc to describe your test steps:tests/specs/my_feature/__test__.jsonc
Add test files
Add input files and expected output:
tests/specs/my_feature/main.ts
tests/specs/my_feature/expected.out
Output Matching
Spec test output files support special matching syntax:[WILDCARD]- Matches 0 or more of any character (like.*in regex), can cross newlines[WILDLINE]- Matches 0 or more characters until end of line[WILDCHAR]- Match the next character[WILDCHARS(5)]- Match any of the next 5 characters[UNORDERED_START]…[UNORDERED_END]- Match lines in any order (useful for non-deterministic output)[# comment]- Line comments
expected.out
Development Workflows
Adding a New CLI Subcommand
Create command handler
Add the command handler in
cli/tools/<command_name>.rs or cli/tools/<command_name>/mod.rsReference examples:- Simple command:
cli/tools/fmt.rs - Complex command:
cli/tools/test/
Modifying or Adding an Extension
Extensions provide native functionality to JavaScript (filesystem, networking, etc.).Updating Dependencies
Debugging
Debugging Rust Code
Using an IDE Debugger
- Set breakpoints in Rust code
- Run tests in debug mode through your IDE (VS Code with rust-analyzer, IntelliJ IDEA, etc.)
Using LLDB
Debugging JavaScript Runtime
Enable the V8 inspector and connect Chrome DevTools:Verbose Logging
Debug Prints
In Rust code:Backtraces
For crashes or panics:Troubleshooting
Build Failures
Error: linking with `cc` failed
Error: linking with `cc` failed
Make sure you have the required system dependencies:
- macOS:
xcode-select --install - Linux: Install
build-essentialor equivalent
Error: failed to download dependencies
Error: failed to download dependencies
- Check your internet connection
- Try
cargo cleanthen rebuild - If behind a proxy, configure cargo accordingly
Slow compile times
Slow compile times
- Use
cargo checkinstead ofcargo buildwhen possible - Use
--bin denoto build only the main binary - Consider using
sccacheormoldlinker for faster builds - Use
cargo-watchfor incremental builds
Test Failures
Spec test failures
Spec test failures
- Check the test output carefully for differences
- Update
.outfiles if output format changed intentionally - Use
[WILDCARD]for non-deterministic parts of output
Flaky tests
Flaky tests
- Add
[UNORDERED_START]/[UNORDERED_END]for order-independent output - Check for race conditions in test code
- May need to increase timeouts or add retries
Permission errors in tests
Permission errors in tests
- Ensure test files have correct permissions
- Check that test setup properly grants necessary permissions
Codebase Navigation
Key Files to Understand
cli/main.rs
Entry point and command routing
cli/args/flags.rs
CLI flag parsing and structure
runtime/worker.rs
Worker/runtime initialization
runtime/permissions.rs
Permission system implementation
cli/module_loader.rs
Module loading and resolution
Common Patterns
- Ops - Rust functions exposed to JavaScript (in
ext/directories) - Extensions - Collections of ops and JS code providing functionality
- Workers - JavaScript execution contexts (main worker, web workers)
- Resources - Managed objects passed between Rust and JS (files, sockets, etc.)
Finding Examples
Performance Tips
Fast Iteration
Use
cargo build --bin deno for faster builds during developmentType Checking
Use
cargo check instead of cargo build when you only need to verify compilationIncremental Builds
Install
cargo-watch for automatic rebuilds on file changesFaster Linking
Use
sccache or the mold linker to speed up linkingGetting Help
When you’re stuck:- Check existing issues on GitHub
- Look at recent PRs for similar changes
- Search the Discord community for discussions
- Ask the maintainers - they’re helpful and responsive!
Need Help?
Join the Deno Discord community for real-time help and discussions