Download the PHP package rossjcooper/laravel-dusk-visual-assert without Composer
On this page you can find all versions of the php package rossjcooper/laravel-dusk-visual-assert. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rossjcooper/laravel-dusk-visual-assert
More information about rossjcooper/laravel-dusk-visual-assert
Files in rossjcooper/laravel-dusk-visual-assert
Package laravel-dusk-visual-assert
Short Description Adds assertions to compare screenshots taken during Laravel Dusk tests
License MIT
Informations about the package laravel-dusk-visual-assert
Laravel Dusk Visual Assert
This package adds assertions to compare screenshots taken during Laravel Dusk tests using the Imagick extension.
Installation
You can install the package via composer:
Configuration
Publish the config file to control default settings:
Usage
The Dusk Browser class now has access to some new methods:
assertScreenshot()
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).
If the images are different, the test will fail and save the image diff so you can inspect the differences.
Example:
assertResponsiveScreenshots()
This method is similar to the assertScreenshot
as above but it screenshots the page at different screen sizes.
Example:
Updating reference images
If you want to update the reference images simply delete them from the tests/Browser/screenshots/references
directory and re-run your tests to generate new ones.
I would recommend committing the reference images to your repository so you can track changes to them over time.
Caveats
When comparing images, the package will expect the screenshots to be the same width and height as the reference images.
If the Dusk environment has changed (headless-mode, window size, etc) then the comparison screenshots could be different sizes and the assertion will fail.
You can change the skip_if_different_window_size
config option to overcome this if you need to use a different Dusk environment temporarily.