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
This package adds assertions to compare screenshots taken during [Laravel Dusk](https://laravel.com/docs/10.x/dusk#taking-a-screenshot) tests using the Imagick extension.
The Dusk Browser class now has access to some new methods:
16
+
17
+
### assertScreenshot()
18
+
19
+
This method will take a screenshot of the current page and compare it to a reference image (generated the first time the test is run).
20
+
21
+
If the images are different, the test will fail and save the image diff so you can inspect the differences.
22
+
23
+
```php
24
+
$browser->assertScreenshot(string $name, float $threshold = 0.0001, int $metric = Imagick::METRIC_MEANSQUAREERROR)
25
+
```
26
+
27
+
Example:
28
+
29
+
```php
30
+
$this->browse(function (Browser $browser) {
31
+
$browser->visit('/')
32
+
->assertScreenshot('home');
33
+
});
34
+
```
35
+
36
+
### assertResponsiveScreenshots()
37
+
38
+
This method is similar to the `assertScreenshot` as above but it screenshots the page at different screen sizes.
39
+
40
+
```php
41
+
$browser->assertResponsiveScreenshots(string $name, float $threshold = 0.0001, int $metric = Imagick::METRIC_MEANSQUAREERROR)
42
+
```
43
+
44
+
Example:
45
+
46
+
```php
47
+
$this->browse(function (Browser $browser) {
48
+
$browser->visit('/')
49
+
->assertResponsiveScreenshots('home');
50
+
});
51
+
```
52
+
53
+
## Updating reference images
54
+
55
+
If you want to update the reference images simply delete them from the `tests/Browser/screenshots` directory and re-run your tests to generate new ones.
56
+
57
+
I would recommend committing the reference images to your repository so you can track changes to them over time.
0 commit comments