Skip to content

Commit bfab22e

Browse files
committed
formatting
1 parent eac3cd3 commit bfab22e

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

.ai/pest/core.blade.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
1-
## Testing
1+
## Pest
2+
3+
### Testing
24
- If you need to verify a feature is working, write or update a Unit / Feature test.
35

4-
# Pest Tests
6+
### Pest Tests
57
- All tests must be written using Pest.
6-
- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files, these are core to the application.
7-
- Tests should test all of the unhappy paths, happy paths, and weird paths.
8+
- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files - these are core to the application.
9+
- Tests should test all of the happy paths, failure paths, and weird paths.
810
- Tests live in the `tests/Feature` and `tests/Unit` directories.
911
- Pest tests look and behave like this:
10-
<code-snippet name="Basic example Pest test" lang="php">
12+
<code-snippet name="Basic Pest Test Example" lang="php">
1113
it('is true', function () {
1214
expect(true)->toBeTrue();
1315
});
1416
</code-snippet>
1517

16-
# Running Tests
17-
- Run the minimal number of tests, using an appropriate filter, before finalizing code edits.
18-
- Run all tests: `php artisan test`.
19-
- Run all tests in a file: `php artisan test tests/Feature/ExampleTest.php`.
20-
- Filter on particular test name: `php artisan test --filter=testName` (recommended after making a change to a related file).
21-
- When the tests relating to your changes are passing, ask the user if they'd like to run the entire test suite to ensure everything is still passing.
18+
### Running Tests
19+
- Run the minimal number of tests using an appropriate filter before finalizing code edits.
20+
- To run all tests: `php artisan test`.
21+
- To run all tests in a file: `php artisan test tests/Feature/ExampleTest.php`.
22+
- To filter on a particular test name: `php artisan test --filter=testName` (recommended after making a change to a related file).
23+
- When the tests relating to your changes are passing, ask the user if they would like to run the entire test suite to ensure everything is still passing.
2224

23-
## Pest Assertions
24-
- When asserting status codes on a response, use the specific method like `assertForbidden`, `assertNotFound` etc, instead of using `assertStatus(403)` or similar, e.g.:
25-
<code-snippet name="Pest asserting postJson response" lang="php">
25+
### Pest Assertions
26+
- When asserting status codes on a response, use the specific method like `assertForbidden` and `assertNotFound` instead of using `assertStatus(403)` or similar, e.g.:
27+
<code-snippet name="Pest Example Asserting postJson Response" lang="php">
2628
it('returns all', function () {
2729
$response = $this->postJson('/api/docs', []);
2830

2931
$response->assertSuccessful();
3032
});
3133
</code-snippet>
3234

33-
## Mocking
34-
- Mocking can be very helpful.
35-
- When mocking, you can use the pest function `Pest\Laravel\mock`, and always import it before usage with `use function Pest\Laravel\mock;`. Alternatively you can use `$this->mock()` if existing tests do.
35+
### Mocking
36+
- Mocking can be very helpful when appropriate.
37+
- 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.
3638
- You can also create partial mocks using the same import or self method.
3739

38-
## Datasets
39-
- Use datasets in Pest to simplify tests which have a lot of duplicated data. This often the case when testing validation rules, so often go with the solution of using datasets when writing tests for validation rules.
40+
### Datasets
41+
- Use datasets in Pest to simplify tests which have a lot of duplicated data. This often the case when testing validation rules, so consider going with this solutionwhen writing tests for validation rules.
4042

41-
<code-snippet name="Pest dataset example" lang="php">
43+
<code-snippet name="Pest Dataset Example" lang="php">
4244
it('has emails', function (string $email) {
4345
expect($email)->not->toBeEmpty();
4446
})->with([

0 commit comments

Comments
 (0)