1---2name: pest3description: Pest framework syntax reference4---56# Pest78## Instructions910- Use `php artisan make:test --pest {name}`.11- Pest tests look and behave like this:12 <code-snippet name="Basic Pest Test Example" lang="php">13 it('is true', function () {14 expect(true)->toBeTrue();15 });16 </code-snippet>1718## Examples1920### Pest Assertions2122- When asserting status codes on a response, use the specific method like `assertForbidden` and `assertNotFound` instead of using `assertStatus(403)` or similar, e.g.:23 <code-snippet name="Pest Example Asserting postJson Response" lang="php">24 it('returns all', function () {25 $response = $this->postJson('/api/docs', []);26 $response->assertSuccessful();27 });28 </code-snippet>2930### Mocking3132- Mocking can be very helpful when appropriate.33- 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.34- You can also create partial mocks using the same import or self method.3536### Datasets3738- 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.3940<code-snippet name="Pest Dataset Example" lang="php">41it('has emails', function (string $email) {42 expect($email)->not->toBeEmpty();43})->with([44 'james' => 'james@laravel.com',45 'taylor' => 'taylor@laravel.com',46]);47</code-snippet>4849## Pest 45051- Pest v4 is a huge upgrade to Pest and offers: browser testing, smoke testing, visual regression testing, test sharding, and faster type coverage.52- Browser testing is incredibly powerful and useful for this project.53- Browser tests should live in `tests/Browser/`.