rstest-debugging
Debug Rstest issues systematically, including performance regressions. First determine whether the slowdown is in build startup or test execution, then run controlled config or code experiments and compare before/after timings.
What this skill does
# 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:
```bash
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 `Duration` value is not enough to decide.
Use these tools in order:
### Use `--trace` when the time distribution is unclear
```bash
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
```bash
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
```bash
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:
```ts
import { defineConfig } from '@rstest/core';
export default defineConfig({
testEnvironment: 'jsdom',
output: {
bundleDependencies: false,
},
});
```
Compare:
- Build or startup duration
- `dist/.rstest-temp` size
- 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:
```ts
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:
```ts
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:
1. Use the verbose reporter to identify the slow file and slow case.
2. Use `--trace` to see whether time is spent in setup hooks, the test body, retries, or teardown.
3. If runtime cost is still unclear, use a profiler:
- `samply` for CPU time distribution
- `--heap-prof` for memory allocation
- `--inspect` for step-through debugging
Common runtime fixes to test one by one:
- Move expensive repeated setup out of `beforeEach` when 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.maxWorkers` settings if worker oversubscription or contention is suspected.
## 5. Compare changes with a single-variable experiment loop
Every optimization attempt must follow this loop:
1. Keep the command fixed.
2. Change exactly one config field or one code path.
3. Rerun the same command.
4. Compare cold and warm timings against the baseline.
5. 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
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.