What is enough to test and maintain an application?
Understanding when to use Cypress (E2E testing) versus unit testing (Jasmine/Karma or Jest) is key to building a reliable and maintainable Angular app. Each has its own purpose and benefits, and ideally, you combine both depending on the scope of what you're testing.
Unit Testing (Jasmine/Karma or Jest)
Best for:
- Testing individual components, services, pipes, directives in isolation.
- Ensuring logic correctness (e.g. functions return correct results).
- Fast feedback loop (runs quickly).
Advantages:
- Fast and easy to debug.
- Encourages good architecture (decoupling).
- Very effective for testing pure logic and component behavior.
Limitations:
- Doesn’t test actual rendering in a real browser.
- Doesn’t catch integration issues (e.g., routing, APIs, DOM behavior).
- Requires mocking a lot of dependencies (can lead to false positives).
End-to-End (E2E) Testing with Cypress
Best for:
- Testing the app as a real user would — in a real browser, with real clicks, navigation, and backend interactions.
- Verifying integration across multiple components, routing, services.
- Critical user flows (login, checkout, form submission, etc.).
Advantages:
- Runs in a real browser → better confidence that the app actually works.
- Simulates real-world usage.
- Built-in wait, retries, and developer-friendly debug tools.
- Easy to write readable, behavior-focused tests.
Limitations:*
- Slower than unit tests.
- Can be flaky if not written carefully (e.g., relying on fixed timeouts).
- Requires running the actual Angular app (more setup).
So, Should You Use Cypress If You Have Unit Tests?
Yes — Cypress complements unit tests.
Scenario | Use Unit Tests | Use Cypress |
Pure logic in services | ✅ Yes | ❌ No |
Component method behavior | ✅ Yes | ❌ No |
DOM interactions (clicks, inputs) | ✅ (shallow) | ✅ (realistic) |
Form validation | ✅ (logic) | ✅ (user experience) |
Login flow | ❌ No | ✅ Yes |
Routing between pages | ❌ No | ✅ Yes |
API + UI integration | ❌ No | ✅ Yes |
Hybrid Strategy (Recommended)
TL;DR Recommendation
Tool | Use for | Benefit |
Jasmine/Karma or Jest | Fast, isolated tests | Quick feedback, high coverage |
Cypress | Full browser, real-user tests | Confidence in real-world usage |
Using only unit tests risks missing integration bugs. Using only E2E tests can be too slow and brittle.
Best practice: Use both together to ensure depth (unit) and breadth (E2E) in your test coverage.