This package enables you to do local visual testing using Laravel Dusk. This does not use any third party services such as Percy.
- PHP 7.3+
- Laravel 8+
- NPX (from NPM) installed and available in
$PATH
You can install the package via composer as a dev dependency:
composer require jamesking56/laravel-visual-diff
- Call the new method
->visualDiff()
for any loaded page in Dusk you want to check for visual changes:
class ExampleTest extends DuskTestCase
{
/**
* A basic browser test example.
*
* @return void
*/
public function testBasicExample()
{
$this->browse(function (Browser $browser) {
$browser->visit('/')
->visualDiff();
});
}
}
Optionally you can name the screenshot: ->visualDiff($name)
-
On the first run, no screenshots will be available to be checked so no diff checking will be done.
-
On subsequent runs, the screenshot file will exist and therefore can be diff checked.
-
If you intentionally want to break the design, update the screenshots:
vendor/bin/phpunit -d --update-screenshots
- We recommend committing the screenshot files to Git, so that the latest screenshot is always available as a reference.
composer tests
Please see GitHub Releases for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email james@jamesking.dev instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.