Install
$ agentstack add skill-rstackjs-agent-skills-rstest-debugging ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Rstest Debugging Workflow
Use this skill when Rstest is slower than expected, slower than Jest or Vitest, slower than a previous Rstest baseline, or when users report that tests spend a long time before starting.
The goal is not to guess a root cause from config names alone. First identify where time is being spent, then change one variable at a time and compare the result.
1. Establish a reproducible baseline
Before changing config or code:
- Pick the narrowest representative command. Prefer a single file, package, or fixture over the whole workspace.
- Record the exact command, working directory, test environment (
node,jsdom,happy-dom, browser mode), and relevant worker settings. - Measure at least one cold run and one warm run with the same command.
- Do not change multiple config fields before the first measurement.
Common baseline commands:
npx rstest run path/to/test-file.test.ts
npx rstest --reporter=verbose path/to/test-file.test.ts
pnpm rstest path/to/test-file.test.ts
If the problem is reported as “there is a long pause before tests even start”, treat that as a build or startup hypothesis until measurements prove otherwise.
2. Classify the slowdown before optimizing
Split the investigation into one of these buckets:
- Build or startup slow: there is a long delay before test cases begin, or small reruns still spend most time preparing the graph.
- Execution slow: tests start quickly, but one or more files or cases take a long time to finish.
- Unclear: a single
Durationvalue is not enough to decide.
Use these tools in order:
Use --trace when the time distribution is unclear
npx rstest run --trace
--trace produces a Perfetto-compatible trace with per-phase, per-suite, and per-case slices. Use it to answer: is the time concentrated in prepare or build phases, or inside test execution?
Use DEBUG=rstest for build-stage clues
DEBUG=rstest npx rstest run
Focus on:
- Long build-related log phases
- Large temporary outputs under
dist/.rstest-temp - Whether a heavy dependency chain or entry causes most of the startup cost
Use the verbose reporter for execution-stage clues
npx rstest --reporter=verbose
Use this to find the slow file, suite, or case before reaching for a profiler.
3. If build or startup is slow
For jsdom and happy-dom, Rstest bundles third-party dependencies by default. That often explains reports like “Rstest is slow before tests even start”.
Check these first:
- Whether a test entry pulls in a large UI, editor, charting, or data-processing package
- Whether style imports or asset imports are causing extra graph traversal
- Whether the test only needs a tiny API surface while bundling a much larger dependency tree
Run one experiment at a time, and rerun the exact same baseline command after each change.
Experiment A: externalize bundled dependencies
For non-browser mode, try:
import { defineConfig } from '@rstest/core';
export default defineConfig({
testEnvironment: 'jsdom',
output: {
bundleDependencies: false,
},
});
Compare:
- Build or startup duration
dist/.rstest-tempsize- Whether the test still behaves correctly
Experiment B: externalize only the heavy packages
If only a few dependencies dominate the graph, prefer a smaller change:
import { defineConfig } from '@rstest/core';
export default defineConfig({
output: {
externals: ['react', 'lodash'],
},
});
Experiment C: restore explicit style stubs when the test does not need real style processing
If a previous Jest setup used moduleNameMapper to stub CSS or SCSS with identity-obj-proxy, compare that behavior explicitly instead of assuming the native Rstest path is equivalent:
import { defineConfig } from '@rstest/core';
export default defineConfig({
tools: {
rspack: (config, { rspack }) => {
config.plugins ??= [];
config.plugins.push(
new rspack.NormalModuleReplacementPlugin(
/\.(css|less|scss)$/,
'identity-obj-proxy',
),
);
},
},
});
Only keep this if the tests do not depend on real style behavior and the timing improvement is measurable.
Experiment D: inspect build-time distribution with Rsdoctor
If startup is still slow and the expensive part is unclear, use Rsdoctor to see whether time is dominated by entries, loaders, plugins, or dependency chains.
4. If test execution is slow
Once startup is acceptable and execution remains slow, stop tuning bundling first. Focus on the runtime path.
Investigate in this order:
- Use the verbose reporter to identify the slow file and slow case.
- Use
--traceto see whether time is spent in setup hooks, the test body, retries, or teardown. - If runtime cost is still unclear, use a profiler:
samplyfor CPU time distribution--heap-proffor memory allocation--inspectfor step-through debugging
Common runtime fixes to test one by one:
- Move expensive repeated setup out of
beforeEachwhen it can be shared safely. - Reduce oversized fixtures or test data created per case.
- Replace real network, filesystem, or timer work with mocks where the integration is not under test.
- Split one huge slow test file into smaller files only if the measured bottleneck is file-local setup or teardown.
- Compare
pool.maxWorkerssettings if worker oversubscription or contention is suspected.
5. Compare changes with a single-variable experiment loop
Every optimization attempt must follow this loop:
- Keep the command fixed.
- Change exactly one config field or one code path.
- Rerun the same command.
- Compare cold and warm timings against the baseline.
- Keep the change only if the improvement is real and behavior is unchanged.
Report the result in a compact table when possible:
| Change | Cold run | Warm run | Outcome | | -------------------------------------------- | -------- | -------- | ------- | | Baseline | | | | | output.bundleDependencies: false | | | | | CSS stub via NormalModuleReplacementPlugin | | | |
Do not stack multiple “maybe faster” changes before measuring. That destroys the ability to attribute the result.
6. Validate the optimization before keeping it
- Rerun the same representative command after each change.
- Confirm behavior is unchanged, not just faster.
- Prefer the smallest config or code change that produces a measurable win.
- If the improvement only appears on warm runs but cold runs are still unacceptable, keep investigating the startup path.
- If the improvement only appears after broad config changes, revert and retest in smaller steps until the actual winning variable is identified.
References
- https://rstest.rs/guide/advanced/profiling
- https://rstest.rs/guide/basic/reporters#verbose-reporter
- https://rstest.rs/config/build/output
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: rstackjs
- Source: rstackjs/agent-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.