Skip to content

Commit 77115b5

Browse files
authored
Merge branch '4.x' into bugfix/phpunit-12-references
2 parents a49a39d + eb46b66 commit 77115b5

3 files changed

Lines changed: 44 additions & 16 deletions

File tree

browser-testing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ To get started with browser testing in Pest, you need to install the Pest Browse
5353
```bash
5454
composer require pestphp/pest-plugin-browser --dev
5555

56+
npm install playwright@latest
5657
npx playwright install
5758
```
5859

pest-v4-is-here-now-with-browser-testing.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
---
22
title: Pest v4 Is Here — Now with Browser Testing
3-
description: Today, were thrilled to announce Pest v4 — our biggest release yet, featuring powerful new browser testing with parallel support and full Laravel integration.
3+
description: Today, we're thrilled to announce Pest v4 — our biggest release yet, featuring powerful new browser testing with parallel support and full Laravel integration.
44
---
55

6-
> Note: Pest v4 is not yet released. Details may change before the final launch.
7-
86
> To get started with Pest v4's new features including browser testing, please refer to the upgrade guide: [Upgrade Guide →](/docs/upgrade-guide).
97
108
- [Browser Testing](#pest-v4-is-here-now-with-browser-testing)
@@ -17,9 +15,13 @@ description: Today, we’re thrilled to announce Pest v4 — our biggest release
1715

1816
# Pest v4 Is Here — Now with Browser Testing
1917

20-
Today (August 21), we’re thrilled to announce the release of **Pest v4**, bringing the biggest testing upgrade yet: powerful **[Browser Testing](/docs/browser-testing)**. Pest’s new browser testing features let you run elegant, maintainable browser tests — with first-class support for Laravel’s testing API and the ability to run tests in parallel. For the first time, this is browser testing that feels as good as writing unit tests.
18+
Today, we're thrilled to announce the release of **Pest v4**, bringing the biggest testing upgrade yet: powerful **[Browser Testing](/docs/browser-testing)**. Pest's new browser testing features let you run elegant, maintainable browser tests — with first-class support for Laravel's testing API and the ability to run tests in parallel. For the first time, this is browser testing that feels as good as writing unit tests.
19+
20+
Here is the creator of Pest, [Nuno Maduro](https://twitter.com/enunomaduro), demoing the new browser testing features in Pest v4 at Laracon US:
21+
22+
[![Pest v4](/assets/pest4_play.png)](https://youtu.be/f5gAgwwwwOI?si=LtPpySZe3tf8qMjz&t=52)
2123

22-
Here is an example using [Laravel](https://laravel.com):
24+
Here is an example of Browser Testing using [Laravel](https://laravel.com):
2325

2426
```php
2527
it('may reset the password', function () {
@@ -34,17 +36,17 @@ it('may reset the password', function () {
3436
->inDarkMode(); // or ->inLightMode()
3537

3638
$page->assertSee('Sign In')
37-
->assertNoJavascriptErrors() // or ->assertNoConsoleLogs()
3839
->click('Forgot Password?')
39-
->fill('email', 'nuno@laravel.com')
40-
->click('Send Reset Link')
40+
->type('email', 'nuno@laravel.com')
41+
->press('Send Reset Link')
4142
->assertSee('We have emailed your password reset link!')
43+
->assertNoJavascriptErrors(); // or ->assertNoConsoleLogs()
4244

4345
Notification::assertSent(ResetPassword::class);
4446
});
4547
```
4648

47-
With Pest v4s browser testing, you can:
49+
With Pest v4's browser testing, you can:
4850
- Seamlessly use **Laravel features** like `Event::fake()`, `assertAuthenticated()`, and model factories
4951
- Use `RefreshDatabase`, even with SQLite in-memory databases, to ensure a clean state for each test
5052
- Test on **multiple browsers** (Chrome, Firefox, Safari)
@@ -61,6 +63,7 @@ To get started with browser testing in Pest, you need to install the Pest Browse
6163
```bash
6264
composer require pestphp/pest-plugin-browser --dev
6365

66+
npm install playwright@latest
6467
npx playwright install
6568
```
6669

@@ -71,24 +74,26 @@ After, you may use the `visit()` function anywhere. Finally, running this test i
7174
Smoke testing your application in real browsers has never been easier. With Pest v4, you can literally visit all your application pages, and ensure they don't throw any JavaScript errors, and they don't log any console errors.
7275

7376
```php
74-
$pages = visit(['/', '/about', '/contact']);
77+
$routes = ['/', '/about', '/contact'];
78+
79+
visit($routes)->assertNoSmoke();
7580

76-
$pages->assertNoJavascriptErrors()
77-
->assertNoConsoleLogs();
81+
// assertNoSmoke() is a shorthand for:
82+
// - assertNoJavascriptErrors()
83+
// - assertNoConsoleLogs()
7884
```
7985

8086
## Visual Regression Testing
8187

82-
Want to ensure your pages look exactly as expected? Pest v4 introduces visual regression testing with the `assertScreenshotsMatches()` assertion. This allows you to take screenshots of your pages and compare them against baseline images, ensuring that your UI remains consistent across changes.
88+
Want to ensure your pages look exactly as expected over time? Pest v4 introduces visual regression testing with the `assertScreenshotsMatches()` assertion. This allows you to take screenshots of your pages and compare them against baseline images, ensuring that your UI remains consistent across changes.
8389

8490
```php
8591
$pages = visit(['/', '/about', '/contact']);
8692

8793
$pages->assertScreenshotsMatches();
8894
```
8995

90-
[image here missing]
91-
96+
![Visual Regression Testing in Pest v4](/assets/pest4_play.png)
9297

9398
This is just a glimpse of what Browser Testing in Pest v4 can do. Find out more about the new features below, and check out the [Browser Testing documentation](/docs/browser-testing) for a complete guide on how to get started.
9499

@@ -173,9 +178,25 @@ As an example, `pr31(f*ck)` means that the word "fuck" was found on line 31.
173178

174179
To learn more about the Profanity plugin and how to configure it, check out the [Profanity documentation](/docs/profanity).
175180

181+
### Skip Locally or On CI
182+
183+
Pest v4 introduces the ability to conditionally skip tests based on the environment. You can use `skipLocally()` to skip tests when running locally, or `skipOnCi` to skip tests when running on a CI server.
184+
185+
```php
186+
it('does not run locally', function () {
187+
// This test will be skipped when running locally
188+
})->skipLocally();
189+
190+
it('does not run on CI', function () {
191+
// This test will be skipped when running on a CI server
192+
})->skipOnCi();
193+
```
194+
176195
### Miscellaneous Improvements
177196

178197
- You may now use `skipLocally()` or `skipOnCi` to conditionally skip tests based on the environment.
198+
- The `not->toHaveSuspiciousCharacters()` arch expectation has been added to help you identify potential suspicious characters in your code. This arch expectation is now enabled by default on the `php` arch preset.
199+
- The expectation `toBeSlug` has been added to help you validate that a string is a valid slug.
179200

180201
### On Top of PHPUnit 12
181202

upgrade-guide.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Upgrade Guide
3-
description: Upgrading To 3.x From 2.x
3+
description: Upgrading To 4.x From 3.x
44
---
55

66
## Upgrading To 4.x From 3.x
@@ -33,6 +33,12 @@ All other Pest maintained plugins should be updated to version `^4.0` in your ap
3333
3434
Pest 4 is built on top of PHPUnit 12. This means that any notable changes made to PHPUnit 12 might have an impact on your test suite. To examine all the changes introduced in PHPUnit 12, please consult the [PHPUnit 12 changelog](https://github.com/sebastianbergmann/phpunit/blob/12.0.0/ChangeLog-12.0.md).
3535

36+
### Watch & Faker Plugin Deprecations
37+
38+
> Likelihood Of Impact: Low
39+
40+
The `pestphp/pest-plugin-watch` and `pestphp/pest-plugin-faker` plugins have been archived and are no longer maintained. The functionality provided by these plugins was not widely used, and therefore, they have been removed from Pest 4.
41+
3642
---
3743

3844
## Upgrading To 3.x From 2.x

0 commit comments

Comments
 (0)