Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Screenshot Laravel Package

spatie/laravel-screenshot

Driver-based Laravel package for taking web page screenshots with great defaults. Use Browsershot (Chromium) or Cloudflare Browser Rendering, customize viewport/format/quality, save to files, and easily fake/assert screenshots in tests.

View on GitHub
Deep Wiki
Context7

title: Testing screenshots weight: 6

In your test, you can call the fake() method on the Screenshot facade to fake the screenshot generation. Because the screenshot generation is faked, your tests will run much faster.

// in your test

use Spatie\LaravelScreenshot\Facades\Screenshot;

beforeEach(function () {
    Screenshot::fake();
});

assertSaved

You can use the assertSaved method to assert that a screenshot was saved. You can pass a string path or a callable.

use Spatie\LaravelScreenshot\Facades\Screenshot;

Screenshot::assertSaved('screenshots/homepage.png');

With a callable for more detailed assertions:

use Spatie\LaravelScreenshot\Facades\Screenshot;

Screenshot::assertSaved(function ($screenshot, string $path) {
    return $path === 'screenshots/homepage.png'
        && $screenshot->url === 'https://example.com';
});

assertUrlIs

You can use the assertUrlIs method to assert that a screenshot was taken of a specific URL:

Screenshot::assertUrlIs('https://example.com');

assertHtmlContains

You can use the assertHtmlContains method to assert that a screenshot was taken from HTML containing a given string:

Screenshot::assertHtmlContains('Hello World');

Queued screenshot assertions

assertQueued

You can use the assertQueued method to assert that a screenshot was queued for generation. You can pass a string path or a callable.

Screenshot::assertQueued('screenshots/homepage.png');

With a callable for more detailed assertions:

Screenshot::assertQueued(function ($screenshot, string $path) {
    return $path === 'screenshots/homepage.png'
        && $screenshot->fullPage === true;
});

assertNotQueued

You can use the assertNotQueued method to assert that no screenshots were queued, or that a specific path was not queued.

// Assert nothing was queued
Screenshot::assertNotQueued();

// Assert a specific path was not queued
Screenshot::assertNotQueued('screenshots/other.png');
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata