PHPackages                             rossjcooper/laravel-dusk-visual-assert - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. rossjcooper/laravel-dusk-visual-assert

ActiveLibrary[Testing &amp; Quality](/categories/testing)

rossjcooper/laravel-dusk-visual-assert
======================================

Adds assertions to compare screenshots taken during Laravel Dusk tests

1.0.6(2y ago)37.5k↓44.1%4[1 issues](https://github.com/rossjcooper/laravel-dusk-visual-assert/issues)MITPHP

Since Sep 19Pushed 2y ago2 watchersCompare

[ Source](https://github.com/rossjcooper/laravel-dusk-visual-assert)[ Packagist](https://packagist.org/packages/rossjcooper/laravel-dusk-visual-assert)[ RSS](/packages/rossjcooper-laravel-dusk-visual-assert/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

Laravel Dusk Visual Assert
==========================

[](#laravel-dusk-visual-assert)

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.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require --dev rossjcooper/laravel-dusk-visual-assert
```

Configuration
-------------

[](#configuration)

Publish the config file to control default settings:

```
php artisan vendor:publish --tag=visual-assert-config
```

Usage
-----

[](#usage)

The Dusk Browser class now has access to some new methods:

### assertScreenshot()

[](#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.

```
$browser->assertScreenshot(string $name, float|null $threshold = null, int|null $metric = null)
```

Example:

```
$this->browse(function (Browser $browser) {
        $browser->visit('/')
            ->assertScreenshot('home');
    });
```

### assertResponsiveScreenshots()

[](#assertresponsivescreenshots)

This method is similar to the `assertScreenshot` as above but it screenshots the page at different screen sizes.

```
$browser->assertResponsiveScreenshots(string $name, float|null $threshold = null, int|null $metric = null)
```

Example:

```
$this->browse(function (Browser $browser) {
        $browser->visit('/')
            ->assertResponsiveScreenshots('home');
    });
```

Updating reference images
-------------------------

[](#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
-------

[](#caveats)

When comparing images, the package will expect the screenshots to be the same width and height as the reference images.

```
Error: Screenshots are not the same size, ensure the screenshots are taken using the same Dusk environment.
Failed asserting that false is true.

```

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.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

7

Last Release

971d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0656ac2c71910f47f1d565d0f1f390d76e476faff7ce13f6e455408c659a4151?d=identicon)[rossjcooper](/maintainers/rossjcooper)

---

Top Contributors

[![rossjcooper](https://avatars.githubusercontent.com/u/3597958?v=4)](https://github.com/rossjcooper "rossjcooper (8 commits)")

---

Tags

duskhacktoberfestlaravellaravel-packagetestingvisual-regressionlaravelimageassertcomparisonscreenshotregressionvisualdusk

### Embed Badge

![Health badge](/badges/rossjcooper-laravel-dusk-visual-assert/health.svg)

```
[![Health](https://phpackages.com/badges/rossjcooper-laravel-dusk-visual-assert/health.svg)](https://phpackages.com/packages/rossjcooper-laravel-dusk-visual-assert)
```

###  Alternatives

[derekmd/laravel-dusk-firefox

Run Laravel Dusk tests in a Firefox browser

4883.4k1](/packages/derekmd-laravel-dusk-firefox)[meyfa/phpunit-assert-gd

PHPUnit matcher/assertions for GD image resources

12553.6k12](/packages/meyfa-phpunit-assert-gd)[code-distortion/adapt

A Laravel package that builds databases for your tests, improving their speed.

2835.5k](/packages/code-distortion-adapt)[protonemedia/laravel-dusk-fakes

Persistent Fakes for Laravel Dusk

2195.1k2](/packages/protonemedia-laravel-dusk-fakes)[appstract/laravel-dusk-safari

Run Dusk tests on Safari

117.2k](/packages/appstract-laravel-dusk-safari)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
