Skip to content

Jamesking56/laravel-visual-diff

Repository files navigation

Laravel Visual Diff

Latest Version on Packagist Build Status Quality Score Total Downloads

This package enables you to do local visual testing using Laravel Dusk. This does not use any third party services such as Percy.

Requirements

  • PHP 7.3+
  • Laravel 8+
  • NPX (from NPM) installed and available in $PATH

Installation

You can install the package via composer as a dev dependency:

composer require jamesking56/laravel-visual-diff

Usage

  1. 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)

  1. On the first run, no screenshots will be available to be checked so no diff checking will be done.

  2. On subsequent runs, the screenshot file will exist and therefore can be diff checked.

  3. If you intentionally want to break the design, update the screenshots:

vendor/bin/phpunit -d --update-screenshots
  1. We recommend committing the screenshot files to Git, so that the latest screenshot is always available as a reference.

Testing

composer tests

Changelog

Please see GitHub Releases for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email james@jamesking.dev instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

About

Visual testing using Laravel Dusk

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages