When to Use This
Use this flow after making a change (feature, bugfix, refactor). It targets only impacted areas to keep feedback fast.Shift Left: You can generate and run tests even before a feature is complete to surface gaps early. Use
testScope: "diff" and run a small subset (testIds) frequently during development.Prerequisites
- TestSprite MCP Installed and configured in your IDE
- Your application runs locally
- Git repo with recent commits for diff analysis
Quick Start
Diff-Scoped Testing Workflow
TestSprite’s diff-scoped workflow is optimized for speed and precision, focusing only on code impacted by recent changes:Step 1: Bootstrap with Diff Scope
The AI callstestsprite_bootstrap_tests with testScope: "diff" to initialize testing for changed code only.

- Process
- What Makes Diff Scope Different
- Project Detection: Reuses existing project type configuration (
frontendorbackend) - Port Discovery: Finds running applications and their ports
- Git Diff Analysis: Identifies modified files and changed lines since last commit
- Scope Definition: Sets testing scope to
diff(changed code only)
Step 2: Analyze Changed Code
The AI callstestsprite_generate_code_summary to analyze only the code impacted by your changes.

- Change Detection: Focuses on modified files and their dependencies
- Impact Mapping: Identifies affected features and components
- Dependency Tracking: Detects new dependencies or framework changes
- Coverage Assessment: Maps changes to existing test coverage gaps
Step 3: Generate/Update Normalized PRD
The AI callstestsprite_generate_standardized_prd to update requirements based on code changes.

- Merge Changes: Integrates new features into existing PRD
- Update Requirements: Adjusts validation criteria for modified flows
- Maintain Context: Preserves overall product goals and existing features
- Focus on Delta: Emphasizes what changed rather than rewriting everything
Tool Called
For minor changes (bug fixes, small refactors), this step may be skipped to save time. For new features or significant changes, it ensures test requirements are aligned with your updates.
Step 4: Create Targeted Test Plans
The AI callstestsprite_generate_frontend_test_plan or testsprite_generate_backend_test_plan based on what changed.

- Targeted Coverage: Tests only impacted features and their dependencies
- Regression Detection: Validates that existing flows still work
- New Functionality: Ensures new features work as expected
- Edge Cases: Covers boundary conditions in changed code
Step 5: Generate & Execute Focused Tests
The AI callstestsprite_generate_code_and_execute to create and run tests for impacted areas only.

- Test Code Generation Process
- Execution Benefits
- Incremental Generation: Creates or updates only tests for changed features
- Smart Reuse: Leverages existing test utilities and helpers
- Focused Execution: Runs only tests that could be affected by changes
- Fast Feedback: Completes in 3-5 minutes vs 10-20 minutes for full suite
Tool Call
Performance Comparison
| Scope | Typical Test Count | Execution Time | Use Case |
|---|---|---|---|
codebase | 20-50 tests | 10-20 min | Initial setup, major releases |
diff | 3-10 tests | 3-5 min | During development, PR validation |
Step 6: Review Diff-Focused Results
TestSprite provides targeted reports showing exactly what your changes affected: Report Highlights:- Changed Features Status: Did your changes work as expected?
- Regression Detection: Did your changes break existing flows?
- New Test Coverage: What new scenarios are now tested?
- Healing Suggestions: Any brittleness introduced by changes?
Example Diff Report Summary
Example Diff Report Summary
Your Changes:
- Modified
src/components/Checkout.tsx(+45, -12) - Added
src/api/payments.ts(+120) - Updated
package.json(added Stripe dependencies)
- ✅ 3 new tests passed - Stripe payment flow works correctly
- ⚠️ 1 test needs update - Checkout button selector changed
- ✅ 5 existing tests passed - No regressions detected
- Update test selector for new checkout button class
- Consider adding test for payment failure scenarios
- All critical paths validated successfully
Best Practices for Diff-Scoped Testing
When to Use Diff Scope
When to Use Diff Scope
✅ Good Use Cases:
- During active feature development
- After bug fixes or refactors
- Before committing changes
- In PR validation workflows
- Initial project onboarding
- Major refactors affecting many files
- Pre-release validation
- When test plan doesn’t exist yet
Iterative Development Tips
Iterative Development Tips
- Commit frequently - Accurate diffs require clean git state
- Run subset first - Use
testIdsto test critical paths quickly - Iterate fast - Run diff tests every 15-30 minutes during dev
- Fix as you go - Address failures immediately while context is fresh
Managing Test Scope
Managing Test Scope
- Start with empty
testIds: []to run all diff-scoped tests - Use specific
testIds: ["TC_001", "TC_005"]for rapid iteration - Add
additionalInstructionto guide test generation context - Keep PRD updated if feature requirements changed
Shift-Left Testing Workflow
TestSprite enables true shift-left testing - run tests early and often, even on incomplete code:1
Start Coding
Begin implementing your feature or fix
2
Early Test Run (Incomplete)
Run diff-scoped tests even if feature isn’t complete. Ask your AI assistant: “Test my in-progress payment feature changes”Outcome: Discover missing validations, edge cases, UX gaps early
3
Iterate & Fix
Address gaps found by tests, continue coding
4
Final Test Run (Complete)
Run again when feature is readyOutcome: High confidence your change works correctly
5
Commit with Confidence
Commit knowing your change is thoroughly tested