Skip to content

Commit 82ea478

Browse files
Add Pest v4 guidelines (#32)
* Add Pest v4 guidelines * guidelines: pest/4: draft * guidelines: pest/4: draft * guidelines: pest/4: add header * Update core.blade.php * Update core.blade.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 5155bdd commit 82ea478

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.ai/pest/4/core.blade.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Pest 4
2+
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+
- Browser testing is incredibly powerful and useful for this project.
5+
- Browser tests should live in `tests/Browser/`.
6+
- Use the `search-docs` tool for detailed guidance on utilizing these features.
7+
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+
- Interact with the page (click, type, scroll, select, submit, drag-and-drop, touch gestures, etc.) when appropriate to complete the test.
11+
- If requested, test on multiple browsers (Chrome, Firefox, Safari).
12+
- If requested, test on different devices and viewports (like iPhone 14 Pro, tablets, or custom breakpoints).
13+
- Switch color schemes (light/dark mode) when appropriate.
14+
- Take screenshots or pause tests for debugging when appropriate.
15+
16+
### Example Tests
17+
@verbatim
18+
<code-snippet name="Pest Browser Test Example" lang="php">
19+
it('may reset the password', function () {
20+
Notification::fake();
21+
22+
$this->actingAs(User::factory()->create());
23+
24+
$page = visit('/sign-in'); // Visit on a real browser...
25+
26+
$page->assertSee('Sign In')
27+
->assertNoJavascriptErrors() // or ->assertNoConsoleLogs()
28+
->click('Forgot Password?')
29+
->fill('email', 'nuno@laravel.com')
30+
->click('Send Reset Link')
31+
->assertSee('We have emailed your password reset link!')
32+
33+
Notification::assertSent(ResetPassword::class);
34+
});
35+
</code-snippet>
36+
@endverbatim
37+
38+
@verbatim
39+
<code-snippet name="Pest Smoke Testing Example" lang="php">
40+
$pages = visit(['/', '/about', '/contact']);
41+
42+
$pages->assertNoJavascriptErrors()->assertNoConsoleLogs();
43+
</code-snippet>
44+
@endverbatim

0 commit comments

Comments
 (0)