Pest tests look and behave like this:
it('is true', function () {
expect(true)->toBeTrue();
});
Examples
Pest Assertions
When asserting status codes on a response, use the specific method like assertForbidden and assertNotFound instead of using assertStatus(403) or similar, e.g.:
it('returns all', function () {
$response = $this->postJson('/api/docs', []);
$response->assertSuccessful();
});
Mocking
Mocking can be very helpful when appropriate.
When mocking, you can use the Pest\Laravel\mock Pest function, but always import it via use function Pest\Laravel\mock; before using it. Alternatively, you can use $this->mock() if existing tests do.
You can also create partial mocks using the same import or self method.
Datasets
Use datasets in Pest to simplify tests which have a lot of duplicated data. This is often the case when testing validation rules, so consider going with this solution when writing tests for validation rules.