Pytest plugin that auto-reports test results with screenshots to VisionSpec
Project description
pytest-visionspec
Pytest plugin that auto-reports test results with screenshots to VisionSpec.
Install
pip install pytest-visionspec
Setup
Set two environment variables:
VS_API_KEY=vs_your_project_api_key
VS_API_URL=https://visionspec-dev.helpfulhuman.xyz
Usage
Tag tests with @pytest.mark.vs("journey-id"):
@pytest.mark.vs("login-happy-path")
def test_login(page):
page.goto("/login")
page.fill("[name=email]", "user@example.com")
page.click("button[type=submit]")
assert page.url == "/dashboard"
The plugin automatically:
- Captures a Playwright screenshot after each test
- Uploads it to VisionSpec storage
- Posts the result (pass/fail + screenshot URL) to VisionSpec
Markers
@pytest.mark.vs("journey-id")— link test to a VisionSpec V1 journey spec@pytest.mark.vs_surface("mobile")— override the reported surface (default:desktop)@pytest.mark.vs_v2("spec-slug", jtbd="jtbd-slug")— link test to a VisionSpec V2 spec (chapters model). Results are buffered and POSTed in one batch at session end to/api/v2/results.
V2 usage (chapters model)
For V2 projects, tag tests with vs_v2 — no screenshot capture, batched reporting:
@pytest.mark.vs_v2("verdict-returns-200", jtbd="get-verdict")
def test_verdict():
r = client.get("/verdict")
assert r.status_code == 200
Get your project's VS_API_KEY via the V2 MCP tool get_project(project) (returns test_reporting.env_vars) or from the "CI / Test runner" tab in V2 project settings.
Results POST once per pytest session. Coverage in V2 get_doc's summary field then shows tested / passing / failing counts per spec.
Page fixture detection
By default, the plugin looks for a page fixture. Configure custom fixture names in pyproject.toml:
[tool.pytest.ini_options]
vs_page_fixtures = ["v2app", "v1app", "page"]
The plugin checks each name in order and uses the first one it finds.
Environment variables
| Variable | Required | Description |
|---|---|---|
VS_API_KEY |
Yes | Project API key from VisionSpec |
VS_API_URL |
Yes | VisionSpec server URL |
VS_SUT_VERSION |
No | Version of the system under test |
VS_VERBOSE |
No | Set to 1 for debug logging |
VS_VERSION |
No | App version metadata |
VS_FRONTEND_VERSION |
No | Frontend version metadata |
VS_BACKEND_VERSION |
No | Backend version metadata |
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_visionspec-0.3.0.tar.gz.
File metadata
- Download URL: pytest_visionspec-0.3.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05e1c35184d212ed83894ccb8bc4222d3bb09b87710707fad869903ed7d2dd82
|
|
| MD5 |
bcf25cd3c90d5ca8960bc44d670b4d20
|
|
| BLAKE2b-256 |
11cb43fbcfa36f1ad5b6f2c4622c837bfb1c9ec4d235d6f4932636c994313bac
|
File details
Details for the file pytest_visionspec-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pytest_visionspec-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8b05d155f7c227807b44ab5a83a6bb69d802d4932d795a7f262bd5f3cc861c0
|
|
| MD5 |
c7e0a112873ece8172455ade12382342
|
|
| BLAKE2b-256 |
710443ca4d0aed91e3178590b74d2fe5ed9e7c8c49b83d91e934198f9b5303d8
|