Testing HTTP Requests Locally
So far, the tests that you’ve added to this application focused on the response you obtained from the REST API. This is acceptable as the requests were less complex than the responses for the commands list and view.
For the add command, the scenario is reversed. The simple response has a status and no body, but the request has more details, including a JSON payload and additional headers. We want our tests to ensure the application sends a valid request so we’re confident it’s going to work properly.
If you were testing this application by connecting directly to the actual API server, it wouldn’t be an issue since the server would throw an error if the request was invalid. But since you’re testing this locally using ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access