You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pest-v4-is-here-now-with-browser-testing.md
+36-13Lines changed: 36 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Pest v4 Is Here — Now with Browser Testing
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.
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.
4
4
---
5
5
6
6
> To get started with Pest v4's new features including browser testing, please refer to the upgrade guide: [Upgrade Guide →](/docs/upgrade-guide).
@@ -15,9 +15,13 @@ description: Today, we’re thrilled to announce Pest v4 — our biggest release
15
15
16
16
# Pest v4 Is Here — Now with Browser Testing
17
17
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.
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
19
20
-
Here is an example using [Laravel](https://laravel.com):
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:
@@ -69,24 +74,26 @@ After, you may use the `visit()` function anywhere. Finally, running this test i
69
74
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.
70
75
71
76
```php
72
-
$pages = visit(['/', '/about', '/contact']);
77
+
$routes = ['/', '/about', '/contact'];
73
78
74
-
$pages->assertNoJavascriptErrors()
75
-
->assertNoConsoleLogs();
79
+
visit($routes)->assertNoSmoke();
80
+
81
+
// assertNoSmoke() is a shorthand for:
82
+
// - assertNoJavascriptErrors()
83
+
// - assertNoConsoleLogs()
76
84
```
77
85
78
86
## Visual Regression Testing
79
87
80
-
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.
81
89
82
90
```php
83
91
$pages = visit(['/', '/about', '/contact']);
84
92
85
93
$pages->assertScreenshotsMatches();
86
94
```
87
95
88
-
[image here missing]
89
-
96
+

90
97
91
98
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.
92
99
@@ -171,9 +178,25 @@ As an example, `pr31(f*ck)` means that the word "fuck" was found on line 31.
171
178
172
179
To learn more about the Profanity plugin and how to configure it, check out the [Profanity documentation](/docs/profanity).
173
180
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
+
174
195
### Miscellaneous Improvements
175
196
176
197
- 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.
0 commit comments