Create an API Test

The first test that we write will be one that acts as the backbone and holds our whole test-driven approach together.

This is going to be a feature test which allows is to make a (faked) request to our API and then make assertions about the response...basically a full end-to-end API test.

We will then let this failing test inform us of our next steps i.e. what code do we need to make this test pass.

Inside of this test we are also going to call two test helper methods which don't yet exist; one for mimicking a request to our API and one for asserting that one json string matches another. One thing I really like about Pest is how easy it is to create your own custom test helpers and expectations.

Branch: https://github.com/GaryClarke/pest-tdd/tree/2-create-api-test

composer.json

Complete and Continue  
Discussion

4 comments