Test and ship Express
Test the HTTP contract
Exercise the application as HTTP instead of calling route handlers like ordinary functions.
9 minute lesson
Before choosing a tool or writing more code, make the requirement concrete. The test suite creates the app with fake dependencies and sends requests without binding a public port.
Black-box request tests cover routing, middleware, parsing, status, headers, body, and error behavior together. The useful target is not encyclopedic coverage. Make one deliberate choice, observe its consequences, and know which requirement would make you revise it.
A common failure is to unit-test req and res mocks until they reproduce a different framework from Express. The happy path may still work, which makes the mistake easy to miss. test public HTTP behavior and reserve unit tests for domain logic that has no transport concerns. Keep the first version small enough that every important input and output remains visible.
This supports the module goal: Ship the notes app with black-box tests, production controls, and a failure matrix that can be rerun after changes. Capture the request, command, trace, screenshot, test result, or other evidence that proves the result.
Write tests for the happy path, malformed input, unauthorized access, missing note, and dependency failure. Change one condition on purpose, predict the result, and compare the prediction with what actually happened.
Lesson completed