Skip to content

How-to Guides

Practical directions for common tasks. Each guide assumes you already have a working test suite — see the tutorial if you are starting from zero.


Testing

Guide Goal
Skip tests temporarily Disable a test or block without deleting it
Filter tests by name Run a subset of tests during development
Run tests in CI Integrate utest into a CI pipeline
Troubleshoot common problems Diagnose and fix frequent failures
Reproduce a failing property Automatically replay local failures and reproduce CI seeds

Mocking

Guide Goal
Mock a module with inject() Scoped mock for code that receives a module as a parameter
Mock multiple modules at once Inject two or more modules in a single call instead of nesting
Patch global state Replace the module import itself for the duration of a test
Save and restore mock state Checkpoint global mock state and roll it back after a test
Mock the filesystem Intercept fs calls with virtual files
Mock a built-in global Intercept warn, system, print, etc.
Mock UCI configuration Provide test UCI packages without touching the real config
Mock ubus calls Stub ubus object/method responses
Mock the event loop Run timer callbacks synchronously without blocking
Mock HTTP requests Return canned responses for outbound HTTP
Use strict mode Fail loudly on any unmocked call
Write a custom proxy Build a proxy for a module with no built-in support
Inspect calls with spy() Assert which functions were called, with which arguments

Assertions

Guide Goal
Use combinators with assert.match() Write flexible, composable assertions beyond exact equality

Contributing

Guide Goal
Add a built-in proxy Ship a proxy for a new module inside the framework
Add an assertion Extend the assert object with a new helper
Add a reporter Add a new output format
Run the regression suite Verify no examples regressed after a change