Profiling
Use --trace, DEBUG=rstest, Rsdoctor, samply, and Node.js built-in profilers to measure where test time and memory go.
Using Agent Skills
Install the rstest-debugging skill when investigating performance regressions with a coding agent. It guides the agent to separate build startup from test execution before changing config or test code:
Common performance bottlenecks
Run --trace first to split build time from test execution time, then follow the matching branch:
- Build time dominates (common in
jsdomorhappy-dom, wherenode_modulesdependencies are bundled by default instead of externalized like innode):- Inspect build logs and temporary output sizes under
dist/.rstest-temp(oroutput.distPath.root) withDEBUG=rstest rstest run. - Externalize all third-party packages with
output.bundleDependencies: false(not supported in Browser Mode) or exclude heavy ones withoutput.externals. - Enable
performance.buildCachefor repeatedrstest runinvocations, or inspect loader/plugin compile time with Rsdoctor.
- Inspect build logs and temporary output sizes under
- Test execution dominates (fast startup, slow files or cases):
- Check per-file and per-case durations with
--reporters=verbose(verbose reporter) or the--tracesummary. - Profile hot runtime code with samply or Node.js profiling (see Profiler).
- Check per-file and per-case durations with
Using --trace
--trace breaks a run into per-phase, per-suite, and per-case slices. Use it when the reporter's single Duration number is not enough to tell where the time is spent.
The flag is opt-in. Each run records per-suite and per-case slices annotated with status and retry count, a heap counter sampled at each phase boundary, and one slice per phase of every test file:
prepare: set up the worker runtime, the global API, and the coverage provider when coverage is enabled.envSetup: install the test environment. Close to zero fornode, and when a non-isolated worker is already pinned to the environment.load: receive the built assets of the test entry. The host-side cost of producing them is reported as a host span instead.setupFiles: evaluate the configured setup files.collect: evaluate the test module and build the suite and case tree, including deferred and asyncdescribecallbacks.tests: run the cases and their hooks.coverage: collect coverage data from the provider. Absent when coverage is disabled, or when the file bailed or threw before this point.teardown: clean up the coverage provider and the worker state, plus the test environment whenisolateis enabled.
Node pools also emit a file:load summary slice covering worker-side asset loading, setup files, test module evaluation, and suite collection (matching TestFileResult.loadDuration).
Browser Mode records only prepare and tests, measured on the host from the messages the page sends.
Rstest writes two files to <rootPath>/.rstest/, and replaces them on every watch rerun:
trace-<timestamp>.summary.md: a markdown summary ranking the slowest phases, files, and test cases. The same content is printed to the terminal.trace-<timestamp>.json: a Perfetto-compatible trace for the visual UI.
Start with the summary. Open the trace when you also need to see how work overlapped across workers.

In a TTY, Rstest starts a local helper server so that the printed link opens the trace directly in the Perfetto UI. In CI, the helper server is not started. Upload the trace file as an artifact and drag it into ui.perfetto.dev instead.
To investigate a slowdown with a Coding Agent, hand it both files: the summary for the ranking, the trace for the full event data. They pair with the rstest-debugging skill.
Using Rsdoctor
Rsdoctor is a build analysis tool that can visually display the compilation time of each loaders and plugins.
When you need to debug Rstest's build outputs or build processes, you can use Rsdoctor for troubleshooting.
Quick start
In Rstest, you can enable @rsdoctor/core analysis as follows:
- Install Rsdoctor:
- Add
RSDOCTOR=trueenv variable before the CLI command:
As Windows does not support the above usage, you can also use cross-env to set environment variables. This ensures compatibility across different systems:
After running the above commands, Rstest will automatically register the Rsdoctor plugin, and after the build is completed, it will open the build analysis page. For complete features, please refer to Rsdoctor document.

Profiler
Check --trace first since it requires no external tooling. When you need lower-level data, pick a profiler based on what you are measuring:
- CPU time distribution: use samply (recommended for profiling both the main process and
forks/vmForksworkers together) or--cpu-prof. - Memory allocation: use
--heap-profin Node.js profiling (samplydoes not collect heap data). - Step-through debugging: see Debugging test workers.
Using samply
Profiling Node.js code on macOS requires Node.js 22.16+.
samply profiles the Rstest main process and test workers together.
Rstest forwards host --perf-prof, --perf-basic-prof, and --interpreted-frames-native-stack flags to forks and vmForks workers. For threads and vmThreads, workers share the host Node.js process, so host-level --perf-prof* flags already apply process-wide (do not pass them via --pool.execArgv, as Node.js worker_threads rejects them with ERR_WORKER_INVALID_EXEC_ARGV).
After the run finishes, samply opens the profile in the Firefox Profiler. Select the Node.js thread to inspect JavaScript execution time.

Node.js profiling
Rstest forwards --cpu-prof*, --heap-prof*, and --diagnostic-dir from the host node process to workers in all pools (forks, vmForks, threads, and vmThreads).
To collect CPU profiles:
To collect heap profiles:
Open the generated .cpuprofile or .heapprofile files in Visual Studio Code or Chrome DevTools.
Host --inspect* flags are stripped from workers and attach only to the main Rstest process. To inspect or step through worker code, use --pool.execArgv=--inspect-brk; see Debugging test workers.