Unit, integration, E2E — what should you test in a form?
Answer out loud or in your head first, then compare.
Answer
A unit test checks a small piece of logic, an integration test checks how parts work together, and E2E checks a scenario through the running app. Where the boundaries lie depends on the team and the environment.
For a form: I test typing data, validation, submitting, the pending state, success and error. I check behaviour the user can see, using labels and element roles.
Example integration test: a wrong password shows a message and doesn't move on; a valid request leads to the expected view. I can control the network with a mock at its boundary.
Pitfall: testing the name of a state variable or every internal hook quickly becomes brittle. In E2E I also verify the real integration, not just mocks.
How did it go? Be honest — “Not yet” puts the question on your review list.
Related questions
- B-P14 · How do unit, integration and end-to-end tests differ? — JavaScript, TypeScript and Node.js