Problem: End-to-end tests are often slow and brittle
Problem: End-to-end tests are often slow and brittle.
Solution: Test the UI and the backend separately, and use contract tests to assure our mocks return the same results as the real thing.
The result: We can test the UI and the backend separately, and be confident that they fit together.
Contract testing tool: Pact.
Do I know people doing contract testing?
If so, what is your experience? And what tools are you using?
How I do contract testing:
1. Use Jest or Vitest to make HTTP calls to the backend.
2. Assert that the response data is what I expected. Use Zod to validate the response shape.
3. Use the same Zod schemas on the frontend. This assures our backend and UI are in sync.