Skip to main content

A pytest fixture for visual testing with Playwright

Project description

Pytest Plugin for Visual Testing with Playwright

Based on pixelmatch-py image comparison library.

Expands assert_snapshot pytest fixture from pytest-playwright-snapshot library

Main Features:

  • snapshots creation on the first run
  • visual review of mismatches
  • failing on --update-snapshots to make users manually review images
  • snapshot name is optional, test_name[browser][os].png is generated by default
  • updated folder structure: snapshots/file_name/test_name/test_name[browser][os].png

Installation

$ pip install pytest-playwright-visual

Usage

This plugin provides a assert_snapshot fixture which is used to create snapshots and compare it.

Example:

def test_myapp(page, assert_snapshot):
    page.goto("https://example.com")
    assert_snapshot(page.screenshot())

Then, run pytest:

$ pytest

The first time you run pytest, snapshots will be created, and you will get the error:

Failed: --> New snapshot(s) created. Please review images

The next run, the snapshots comparison will take place.

To update snapshots, run:

$ pytest --update-snapshots

After updating, tests will fail and you will need to review images.

In case of a mismatch, snapshot_tests_failures folder will be created with Actual_.., Expected_.. and Diff_.. images generated.

Folder Structure Example

img_2.png

Threshold

There is threshold option which can be used to set the threshold for the comparison of the screenshots: 0 to 1. Default is 0.1

License

Apache 2.0 LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-playwright-visual-2.0.0.tar.gz (219.0 kB view details)

Uploaded Source

Built Distribution

pytest_playwright_visual-2.0.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file pytest-playwright-visual-2.0.0.tar.gz.

File metadata

File hashes

Hashes for pytest-playwright-visual-2.0.0.tar.gz
Algorithm Hash digest
SHA256 178ad6357ff0e5aa8d779960a5d5a4094ebabedc4373487c87afa9050312a41d
MD5 4fb172ed2d6e77facfb67bf6e99d20e2
BLAKE2b-256 0738cc6e4d2b19b28ababa6a730a90ea1cc1c483eb2ebf80834697c71d76da68

See more details on using hashes here.

File details

Details for the file pytest_playwright_visual-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_playwright_visual-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97984aca838ee310ded1a4bfddd5e558ead0aa9a21b55841f7e8e6f248fd0164
MD5 5de7d488649220b683e81d44ce1685a1
BLAKE2b-256 ab9cd2f46a85772846577d68a6f3d16e86206ea9e4db82884c81f7df4ed9e335

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page