Svelte Test Fix Processor
A command template for svelte workflows. Streamlines development with pre-configured patterns and best practices.
Svelte Test Fix Processor
Troubleshoot and fix failing tests in Svelte and SvelteKit projects by analyzing error messages, identifying failure patterns, and applying targeted fixes.
When to Use This Command
Run this command when...
- Your Svelte component tests are failing and you need systematic diagnosis of the root cause from error messages and stack traces
- You have flaky tests that pass intermittently and need stabilization through proper async handling, cleanup, or mocking
- Your test suite broke after a Svelte, SvelteKit, or testing library version upgrade and needs compatibility fixes
Do NOT use this command when...
- You need to write tests from scratch -- use the test creation command instead
- Your tests are passing but you want to improve coverage or refactor test structure
Quick Start
# .claude/commands/svelte-test-fix-processor.md # Fix failing Svelte tests Fix tests: $ARGUMENTS
# Run the command claude "svelte-test-fix-processor fix TypeError: Cannot read properties of undefined in UserProfile.test.ts"
Expected output:
- Error analysis with root cause identification
- Missing mock or setup dependency detection
- Code fix for the failing test
- Regression prevention recommendation
- Verification command to confirm the fix
Core Concepts
| Concept | Description |
|---|---|
| Error Classification | Categorizing failures as setup, rendering, async, mock, or assertion errors |
| Flaky Test Detection | Identifying tests that fail intermittently due to timing or state leaks |
| Mock Diagnosis | Detecting missing or incorrectly configured mocks for SvelteKit modules |
| Cleanup Verification | Ensuring component cleanup runs between tests to prevent state leaks |
| Version Compatibility | Checking testing library API changes across version upgrades |
Test Fix Pipeline:
Failing Test + Error Message
|
[Classify Error Type]
|
+----+----+----+----+
| | | | |
Setup Render Async Mock Assert
| | | | |
[Identify Root Cause]
|
[Generate Fix]
|
[Verify Fix Passes]
|
Stable Test
Configuration
| Parameter | Default | Description |
|---|---|---|
| Test Runner | Auto-detect | Vitest, Jest, or Playwright based on project config |
| Error Source | Test output | Error message, file path, or test name to diagnose |
| Fix Scope | Single test | Whether to fix one test or scan for similar failures |
| Verification | Run after fix | Whether to execute the test after applying the fix |
| Regression Check | Suggest guard | Whether to recommend preventing similar future failures |
Best Practices
- Include the full error message -- copy the complete error output including stack trace in your arguments for accurate root cause analysis
- Mention recent changes -- if tests broke after an upgrade or refactor, state what changed so the fixer can correlate the failure with the change
- Fix one test at a time -- resolve failures individually to understand each root cause rather than applying broad fixes that may mask underlying issues
- Check for state leaks -- if multiple tests fail, the first failure may contaminate subsequent tests through leaked state. Fix the first failure first
- Update test utilities -- after fixing, check if your test helper functions need the same fix applied to prevent similar failures in future tests
Common Issues
- Cannot find module errors -- SvelteKit alias imports ($lib/, $app/) need mock configuration in vitest.config.ts. Add the resolve.alias section matching your svelte.config.js
- Component renders but events do not fire -- use await fireEvent and await tick() to ensure Svelte reactive updates complete before asserting on event effects
- Tests pass individually but fail together -- state from one test leaks into the next. Add cleanup() calls in afterEach and verify mocks are reset between tests
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.