Critical Business Logic Has No Test Coverage
Your test suite covers utility functions and simple CRUD operations but completely misses the critical business logic: payment processing, access control checks, data transformations, and state machine transitions. The parts of your code that are most likely to cause catastrophic failures if broken have zero test coverage.
Claude Code tends to generate tests for the easiest-to-test code (pure functions, simple helpers) while skipping the complex, stateful, integration-heavy code that actually needs testing the most. The coverage report may show 70% overall but the missing 30% contains all the high-risk logic.
This becomes painfully apparent when a 'small refactor' of the payment flow introduces a bug that charges customers the wrong amount, and no test catches it before production.
Error Messages You Might See
Common Causes
- Complex setup avoided — Tests for payment flows require Stripe test mode, database seeding, and multi-step setup that AI skips
- External service dependencies — Code that calls external APIs is left untested because mocking the API is complex
- State machine transitions untested — Status changes (pending -> processing -> completed -> failed) and their edge cases have no coverage
- Error handling paths untested — Only the happy path is tested; what happens on timeout, invalid input, or partial failure is unknown
- Coverage metrics misleading — Line coverage is high because simple code is tested, but branch coverage on critical paths is zero
How to Fix It
- Identify critical paths first — List your top 10 most important features (payment, auth, data export). These get tests first regardless of overall coverage
- Write integration tests for critical flows — Test the full flow from request to database, using test databases and service test modes (Stripe test keys)
- Test every state transition — For each status field, test every valid transition AND verify invalid transitions are rejected
- Test error handling explicitly — Force errors (network timeouts, invalid data, permission denied) and verify the app handles them gracefully
- Use branch coverage, not line coverage — Configure your coverage tool to report branch coverage. Aim for 100% branch coverage on critical paths
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
What should I test first when coverage is low?
Prioritize by risk: payment processing, authentication and authorization, data mutations that can't be undone, and any code that handles money or personal data. These are the paths where bugs cause the most damage.
How do I test code that calls external APIs?
Use the service's test mode (Stripe test keys, SendGrid sandbox) for integration tests. Use recorded HTTP responses (nock, VCR, responses) for unit tests. Test both success and error responses from the API.