|
1 | 1 | ## Pest 4 |
2 | 2 |
|
3 | | -- Pest v4 is a huge upgrade offering: browser testing, smoke testing, visual regression testing, test sharding, faster type coverage, and profanity checking. |
| 3 | +- Pest v4 is a huge upgrade to Pest and offers: browser testing, smoke testing, visual regression testing, test sharding, and faster type coverage. |
4 | 4 | - Browser testing is incredibly powerful and useful for this project. |
5 | 5 | - Browser tests should live in `tests/Browser/`. |
6 | | -- Use the `search-docs` tool for detailed guidance on utilising these features. |
| 6 | +- Use the `search-docs` tool for detailed guidance on utilizing these features. |
7 | 7 |
|
8 | | -## Browser testing |
9 | | -- You can use Laravel features like `Event::fake()`, `assertAuthenticated()`, and model factories within browser tests, as well as `RefreshDatabase` (when needed) to ensure a clean state for each test. |
10 | | -- Test on multiple browsers (Chrome, Firefox, Safari). |
11 | | -- Test on different devices and viewports (like iPhone 14 Pro, tablets, or custom breakpoints). |
12 | | -- Switch color schemes (light/dark mode). |
13 | | -- Interact with the page (click, type, scroll, select, submit, drag-and-drop, touch gestures, etc.). |
14 | | -- Take screenshots or pause tests for debugging. |
| 8 | +### Browser Testing |
| 9 | +- You can use Laravel features like `Event::fake()`, `assertAuthenticated()`, and model factories within Pest v4 browser tests, as well as `RefreshDatabase` (when needed) to ensure a clean state for each test. |
| 10 | +- If requested, test on multiple browsers (Chrome, Firefox, Safari). |
| 11 | +- If requested, test on different devices and viewports (like iPhone 14 Pro, tablets, or custom breakpoints). |
| 12 | +- Switch color schemes (light/dark mode) when appropriate. |
| 13 | +- Interact with the page (click, type, scroll, select, submit, drag-and-drop, touch gestures, etc.) when appropriate to complete the test. |
| 14 | +- Take screenshots or pause tests for debugging when appropriate. |
15 | 15 |
|
| 16 | +### Example Tests |
16 | 17 | @verbatim |
17 | | -<code-snippet name="Pest browser test example" lang="php"> |
| 18 | +<code-snippet name="Pest Browser Test Example" lang="php"> |
18 | 19 | it('may reset the password', function () { |
19 | 20 | Notification::fake(); |
| 21 | + |
20 | 22 | $this->actingAs(User::factory()->create()); |
21 | 23 |
|
22 | | - $page = visit('/sign-in') // visit on a real browser... |
23 | | - ->on()->mobile() // or ->desktop(), ->tablet(), etc... |
24 | | - ->inDarkMode(); // or ->inLightMode() |
| 24 | + $page = visit('/sign-in'); // Visit on a real browser... |
25 | 25 |
|
26 | 26 | $page->assertSee('Sign In') |
27 | 27 | ->assertNoJavascriptErrors() // or ->assertNoConsoleLogs() |
|
34 | 34 | }); |
35 | 35 | </code-snippet> |
36 | 36 | @endverbatim |
| 37 | + |
37 | 38 | @verbatim |
38 | | -<code-snippet name="Pest smoke testing example" lang="php"> |
| 39 | +<code-snippet name="Pest Smoke Testing Example" lang="php"> |
39 | 40 | $pages = visit(['/', '/about', '/contact']); |
| 41 | + |
40 | 42 | $pages->assertNoJavascriptErrors()->assertNoConsoleLogs(); |
41 | 43 | </code-snippet> |
42 | 44 | @endverbatim |
0 commit comments