PHPackages                             cetera-labs/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. [Image &amp; Media](/categories/media)
4. /
5. cetera-labs/laravel-dusk-visual-assert

ActiveLibrary[Image &amp; Media](/categories/media)

cetera-labs/laravel-dusk-visual-assert
======================================

Adds assertions to compare screenshots taken during Laravel Dusk tests

1.1.3(3mo ago)02.0kMITPHP

Since Nov 4Pushed 3mo agoCompare

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

READMEChangelog (6)Dependencies (1)Versions (7)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

40

—

FairBetter than 88% of packages

Maintenance79

Regular maintenance activity

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 65.2% 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 ~88 days

Recently: every ~110 days

Total

6

Last Release

112d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/533411?v=4)[cetera](/maintainers/cetera)[@Cetera](https://github.com/Cetera)

---

Top Contributors

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

---

Tags

laravelimageassertcomparisonscreenshotregressionvisualdusk

### Embed Badge

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

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

###  Alternatives

[urlbox/screenshots

Use urlbox to easily generate website thumbnail screenshots from a URL

14250.4k](/packages/urlbox-screenshots)

PHPackages © 2026

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