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
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
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
Built Distribution
File details
Details for the file pytest-playwright-visual-2.1.1.tar.gz
.
File metadata
- Download URL: pytest-playwright-visual-2.1.1.tar.gz
- Upload date:
- Size: 219.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9fc84c86b1773c8d8639dc9672c64d5ed00416d3e9b25190bbd112c65300167 |
|
MD5 | 3cb2cabcb31f9b53c08e9d32ce8c38c8 |
|
BLAKE2b-256 | 377802e215542d4b2f16280ceadc0a95c1dec062eae84f9eef2f22242c3d73f3 |
File details
Details for the file pytest_playwright_visual-2.1.1-py3-none-any.whl
.
File metadata
- Download URL: pytest_playwright_visual-2.1.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6be7f1cfcc4c921972e8dee672663a624649520bd02eba9c66b43d6f03c1827e |
|
MD5 | bf3138fd1d6bb27851062f7e8b52989b |
|
BLAKE2b-256 | 29f78480b6d525d21a086fb764a4c10a39f58a1b3ec31a1fbe7d3dec265a6123 |