Metadata-Version: 2.4
Name: pytest-visionspec
Version: 0.2.1
Summary: Pytest plugin that auto-reports test results with screenshots to VisionSpec
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: pytest>=7.0
Requires-Dist: httpx>=0.24

# pytest-visionspec

Pytest plugin that auto-reports test results with screenshots to [VisionSpec](https://visionspec-dev.helpfulhuman.xyz).

## Install

```bash
pip install pytest-visionspec
```

## Setup

Set two environment variables:

```bash
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")`:

```python
@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:
1. Captures a Playwright screenshot after each test
2. Uploads it to VisionSpec storage
3. Posts the result (pass/fail + screenshot URL) to VisionSpec

## Markers

- `@pytest.mark.vs("journey-id")` — link test to a VisionSpec journey spec
- `@pytest.mark.vs_surface("mobile")` — override the reported surface (default: `desktop`)

## Page fixture detection

By default, the plugin looks for a `page` fixture. Configure custom fixture names in `pyproject.toml`:

```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 |
