Skip to content

Commit 351acdf

Browse files
committed
Docs: Laravel Rust (sc-8502), screenshot and snapshot tests with snapshot-testing-laravel under visualci test -- cargo test: install, CI, how names, platforms, ignore rules and thresholds appear on VisualCI; listed on the docs home, the sidebar, llms.txt and install.md; skill visualci-laravel-rust; plugin 0.1.35
1 parent 9addb28 commit 351acdf

10 files changed

Lines changed: 216 additions & 6 deletions

File tree

‎.claude-plugin/marketplace.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"plugins": [
66
{
77
"name": "visualci",
8-
"version": "0.1.33",
8+
"version": "0.1.35",
99
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
1010
"author": { "name": "DocSpring", "url": "https://visualci.com" },
1111
"homepage": "https://visualci.com/docs/skills/",

‎.claude-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "visualci",
3-
"version": "0.1.33",
3+
"version": "0.1.35",
44
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
55
"author": { "name": "DocSpring", "url": "https://visualci.com" },
66
"homepage": "https://visualci.com/docs/skills/",

‎.cursor-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "visualci",
33
"displayName": "VisualCI",
4-
"version": "0.1.33",
4+
"version": "0.1.35",
55
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
66
"author": {
77
"name": "DocSpring"

‎gemini-extension.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "visualci",
3-
"version": "0.1.33",
3+
"version": "0.1.35",
44
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
55
"mcpServers": {
66
"visualci": {

‎server/frontend/content/docs/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A change doesn't fail the build. The pull request's GitHub check waits while you
1515

1616
## What you can send
1717

18-
- **Snapshot tests** that your test framework already writes: [Jest](/docs/snapshots/jest/), [Vitest](/docs/snapshots/vitest/), [insta](/docs/snapshots/insta/), [syrupy](/docs/snapshots/syrupy/) and [rspec-snapshot](/docs/snapshots/rspec-snapshot/).
18+
- **Snapshot tests** that your test framework already writes: [Jest](/docs/snapshots/jest/), [Vitest](/docs/snapshots/vitest/), [insta](/docs/snapshots/insta/), [syrupy](/docs/snapshots/syrupy/), [rspec-snapshot](/docs/snapshots/rspec-snapshot/) and [Laravel Rust](/docs/snapshots/laravel-rust/) (screenshots too).
1919
- **[Screenshots](/docs/screenshots/)** from browsers and mobile apps.
2020
- **[PDFs](/docs/pdfs/)**, rendered page by page on VisualCI's servers.
2121

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: Laravel Rust
3+
description: Screenshot and snapshot tests for Laravel Rust apps with snapshot-testing-laravel, reviewed on VisualCI instead of committed as files.
4+
skill: visualci-laravel-rust
5+
skill_description: Sets up VisualCI for a Laravel Rust app's tests with the snapshot-testing-laravel crate: browser screenshots and HTML, JSON and text snapshots of responses, run under `visualci test -- cargo test`, with names, platforms, ignore rules and thresholds as VisualCI sees them. Use when a Laravel Rust project uses snapshot-testing-laravel, or wants screenshot or snapshot tests with VisualCI. Not for other Rust projects (see visualci-insta) or other frameworks.
6+
---
7+
8+
[snapshot-testing-laravel](https://github.com/DocSpring/snapshot-testing-laravel-rs) is snapshot testing for [Laravel Rust](https://laravel.com/rust) apps: browser screenshots, plus HTML, JSON and text snapshots of your responses. On its own it keeps baselines as files in your repository. With `VISUALCI_TOKEN` set, it sends every snapshot to VisualCI instead, through the `visualci` CLI, and changes wait for review there.
9+
10+
```rust
11+
use laravel::testing::prelude::*;
12+
use snapshot_testing_laravel::prelude::*;
13+
14+
#[laravel::test]
15+
async fn the_pricing_page_looks_right(app: Application) -> laravel::Result<()> {
16+
let browser = app.browse().await?;
17+
browser.visit("/pricing").await?.assert_see("Pro").await?;
18+
browser.assert_screenshot("pricing/desktop").await?;
19+
browser.resize(390, 844).await?.assert_screenshot("pricing/mobile").await?;
20+
Ok(())
21+
}
22+
23+
#[laravel::test]
24+
async fn the_api_matches_its_snapshot(app: Application) {
25+
app.get("/api/users/1")
26+
.await
27+
.assert_ok()
28+
.assert_matches_snapshot_ignoring("api/users/show", ["$.updated_at"]);
29+
}
30+
```
31+
32+
The crate's [README](https://github.com/DocSpring/snapshot-testing-laravel-rs#readme) covers writing the tests: browser steps, element screenshots, the snapshot assertions and the example app. This page covers running them with VisualCI.
33+
34+
## 1. Install
35+
36+
```toml
37+
[dev-dependencies]
38+
snapshot-testing-laravel = "0.1"
39+
```
40+
41+
Browser tests need Chrome or Chromium. Screenshots change a little between Chrome versions, so pin one, the same locally and in CI:
42+
43+
```sh
44+
npx playwright@1.65.2 install --with-deps --only-shell chromium
45+
```
46+
47+
For snapshots without a browser, `default-features = false` leaves the browser out.
48+
49+
Then the CLI, and a project token (see [Quick start](/docs/quick-start/)):
50+
51+
```sh
52+
curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.10 sh
53+
export VISUALCI_TOKEN=vci_...
54+
```
55+
56+
## 2. Run the tests under visualci test
57+
58+
```sh
59+
visualci test -- cargo test
60+
```
61+
62+
`cargo test` runs each file in `tests/` as its own process. [`visualci test`](/docs/reference/cli/#visualci-test) creates one build for the whole run, so every one of them adds to it, and finalizes the build when `cargo test` ends, even when tests fail. It exits with `cargo test`'s status when that failed.
63+
64+
- **Under `visualci test`** (in CI, or on your machine), a changed snapshot doesn't fail its test. The run ends with what changed, with links, and on a pull request the VisualCI check waits until the change is reviewed.
65+
- **Plain `cargo test`** with `VISUALCI_TOKEN` set (and no `VISUALCI_BUILD_ID`) is a local run: each test process makes a local build, and each test fails once, listing every snapshot it changed with a link to review it. `SNAPSHOT_FAIL_FAST=1` (or `VISUALCI_FAIL_FAST=1`) fails a browser test at its first changed screenshot instead.
66+
67+
Approving a local run's change on VisualCI makes it your branch's baseline.
68+
69+
With `VISUALCI_TOKEN` set, nothing is written to `tests/__snapshots__` or `tests/__screenshots__`: the baselines live on VisualCI. If you kept them in git before, remove those folders. The first build becomes the baseline, or in a project that already has builds, the snapshots show as added once, to approve. `VISUALCI_DISABLED=1` compares with the files again, without sending anything.
70+
71+
On GitHub Actions:
72+
73+
```yaml
74+
- uses: actions/setup-node@v4
75+
with:
76+
node-version: 22
77+
- run: npx -y playwright@1.65.2 install --with-deps --only-shell chromium
78+
- run: |
79+
curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.10 VISUALCI_INSTALL_DIR="$HOME/bin" sh
80+
echo "$HOME/bin" >> "$GITHUB_PATH"
81+
- run: visualci test -- cargo test --locked
82+
env:
83+
VISUALCI_TOKEN: ${{ secrets.VISUALCI_TOKEN }}
84+
```
85+
86+
The crate runs `visualci` from the `PATH` (or `VISUALCI_CLI`). Check out with `fetch-depth: 0` so VisualCI can find each commit's baseline (see [GitHub Actions](/docs/ci/github-actions/)).
87+
88+
## How snapshots appear on VisualCI
89+
90+
- **Names** are the names in your tests, as they are: `assert_screenshot("settings/billing/390-dark")` is `settings/billing/390-dark` on VisualCI. Keep them stable and readable, never a counter or a timestamp.
91+
- **Text snapshots** (HTML, JSON and text) have no platform. VisualCI compares HTML with attributes sorted and JSON with keys sorted, as the crate does, and shows JSON changes by path (`items[3].price: 10 → 12`).
92+
- **Screenshots** carry the crate's platform, `chromium-linux`, `chromium-mac` or `chromium-windows` (`SNAPSHOT_PLATFORM` or `BrowserOptions::platform` sets another), so each platform keeps its own baselines. VisualCI also keeps separate sets for CI and for local runs on a Mac or Linux (see [Local runs](/docs/local-runs/#environments)).
93+
- **Ignore rules** given in a test (`.ignoring(["$.created_at", r"ord_[0-9a-z]{24}"])`, rules starting with `$` are JSON paths and the rest regular expressions) go with that snapshot, and VisualCI applies them before comparing. Rules for many snapshots at once go in [`visualci.yml`](/docs/reference/config/).
94+
- **`BrowserOptions::threshold(0.1)`** goes with each screenshot as its own threshold, VisualCI's perceptual colour threshold. Whether anti-aliased pixels count follows the project's setting.
95+
96+
For screenshots that don't change on every run (fixed fake data, a frozen clock with `app.travel_to(..)`, no fonts or images from other sites), see [Deterministic screenshots](/docs/screenshots/deterministic/).
97+
98+
## Reviewing the changes
99+
100+
When something changed, your coding agent reads it over VisualCI's MCP server (`get_build`, then `get_snapshot`) or with `visualci build show`, checks it against the code, and approves it or fixes the code. See [Coding agents](/docs/agents/).

‎server/frontend/public/install.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Look at the repository and list what it already produces:
2222
rspec-snapshot `.snap`;
2323
- screenshots: Playwright, Cypress, Capybara or other browser tests that save images;
2424
- PDFs a test suite generates.
25+
- a Laravel Rust app: its tests can take screenshots and snapshots with the snapshot-testing-laravel crate
26+
(https://visualci.com/docs/snapshots/laravel-rust.md).
2527

2628
Prefer what exists. If there's nothing, propose a handful of screenshots of the main screens, and ask the person before
2729
adding tests.

‎server/frontend/src/docs/nav.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const docsSections: DocsSection[] = [
2121
},
2222
{
2323
title: 'Snapshot tests',
24-
slugs: ['snapshots/jest', 'snapshots/vitest', 'snapshots/insta', 'snapshots/syrupy', 'snapshots/rspec-snapshot'],
24+
slugs: ['snapshots/jest', 'snapshots/vitest', 'snapshots/insta', 'snapshots/syrupy', 'snapshots/rspec-snapshot', 'snapshots/laravel-rust'],
2525
},
2626
{
2727
title: 'Visual tests',
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
name: visualci-laravel-rust
3+
description: "Sets up VisualCI for a Laravel Rust app's tests with the snapshot-testing-laravel crate: browser screenshots and HTML, JSON and text snapshots of responses, run under `visualci test -- cargo test`, with names, platforms, ignore rules and thresholds as VisualCI sees them. Use when a Laravel Rust project uses snapshot-testing-laravel, or wants screenshot or snapshot tests with VisualCI. Not for other Rust projects (see visualci-insta) or other frameworks."
4+
license: Apache-2.0
5+
metadata:
6+
docs: https://visualci.com/docs/snapshots/laravel-rust.md
7+
---
8+
9+
<!-- Generated from server/frontend/content/docs/snapshots/laravel-rust.md by server/frontend/scripts/skills.mjs. Edit the page. -->
10+
11+
# Laravel Rust
12+
13+
[snapshot-testing-laravel](https://github.com/DocSpring/snapshot-testing-laravel-rs) is snapshot testing for [Laravel Rust](https://laravel.com/rust) apps: browser screenshots, plus HTML, JSON and text snapshots of your responses. On its own it keeps baselines as files in your repository. With `VISUALCI_TOKEN` set, it sends every snapshot to VisualCI instead, through the `visualci` CLI, and changes wait for review there.
14+
15+
```rust
16+
use laravel::testing::prelude::*;
17+
use snapshot_testing_laravel::prelude::*;
18+
19+
#[laravel::test]
20+
async fn the_pricing_page_looks_right(app: Application) -> laravel::Result<()> {
21+
let browser = app.browse().await?;
22+
browser.visit("/pricing").await?.assert_see("Pro").await?;
23+
browser.assert_screenshot("pricing/desktop").await?;
24+
browser.resize(390, 844).await?.assert_screenshot("pricing/mobile").await?;
25+
Ok(())
26+
}
27+
28+
#[laravel::test]
29+
async fn the_api_matches_its_snapshot(app: Application) {
30+
app.get("/api/users/1")
31+
.await
32+
.assert_ok()
33+
.assert_matches_snapshot_ignoring("api/users/show", ["$.updated_at"]);
34+
}
35+
```
36+
37+
The crate's [README](https://github.com/DocSpring/snapshot-testing-laravel-rs#readme) covers writing the tests: browser steps, element screenshots, the snapshot assertions and the example app. This page covers running them with VisualCI.
38+
39+
## 1. Install
40+
41+
```toml
42+
[dev-dependencies]
43+
snapshot-testing-laravel = "0.1"
44+
```
45+
46+
Browser tests need Chrome or Chromium. Screenshots change a little between Chrome versions, so pin one, the same locally and in CI:
47+
48+
```sh
49+
npx playwright@1.65.2 install --with-deps --only-shell chromium
50+
```
51+
52+
For snapshots without a browser, `default-features = false` leaves the browser out.
53+
54+
Then the CLI, and a project token (see [Quick start](https://visualci.com/docs/quick-start.md)):
55+
56+
```sh
57+
curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.10 sh
58+
export VISUALCI_TOKEN=vci_...
59+
```
60+
61+
## 2. Run the tests under visualci test
62+
63+
```sh
64+
visualci test -- cargo test
65+
```
66+
67+
`cargo test` runs each file in `tests/` as its own process. [`visualci test`](https://visualci.com/docs/reference/cli.md#visualci-test) creates one build for the whole run, so every one of them adds to it, and finalizes the build when `cargo test` ends, even when tests fail. It exits with `cargo test`'s status when that failed.
68+
69+
- **Under `visualci test`** (in CI, or on your machine), a changed snapshot doesn't fail its test. The run ends with what changed, with links, and on a pull request the VisualCI check waits until the change is reviewed.
70+
- **Plain `cargo test`** with `VISUALCI_TOKEN` set (and no `VISUALCI_BUILD_ID`) is a local run: each test process makes a local build, and each test fails once, listing every snapshot it changed with a link to review it. `SNAPSHOT_FAIL_FAST=1` (or `VISUALCI_FAIL_FAST=1`) fails a browser test at its first changed screenshot instead.
71+
72+
Approving a local run's change on VisualCI makes it your branch's baseline.
73+
74+
With `VISUALCI_TOKEN` set, nothing is written to `tests/__snapshots__` or `tests/__screenshots__`: the baselines live on VisualCI. If you kept them in git before, remove those folders. The first build becomes the baseline, or in a project that already has builds, the snapshots show as added once, to approve. `VISUALCI_DISABLED=1` compares with the files again, without sending anything.
75+
76+
On GitHub Actions:
77+
78+
```yaml
79+
- uses: actions/setup-node@v4
80+
with:
81+
node-version: 22
82+
- run: npx -y playwright@1.65.2 install --with-deps --only-shell chromium
83+
- run: |
84+
curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.10 VISUALCI_INSTALL_DIR="$HOME/bin" sh
85+
echo "$HOME/bin" >> "$GITHUB_PATH"
86+
- run: visualci test -- cargo test --locked
87+
env:
88+
VISUALCI_TOKEN: ${{ secrets.VISUALCI_TOKEN }}
89+
```
90+
91+
The crate runs `visualci` from the `PATH` (or `VISUALCI_CLI`). Check out with `fetch-depth: 0` so VisualCI can find each commit's baseline (see [GitHub Actions](https://visualci.com/docs/ci/github-actions.md)).
92+
93+
## How snapshots appear on VisualCI
94+
95+
- **Names** are the names in your tests, as they are: `assert_screenshot("settings/billing/390-dark")` is `settings/billing/390-dark` on VisualCI. Keep them stable and readable, never a counter or a timestamp.
96+
- **Text snapshots** (HTML, JSON and text) have no platform. VisualCI compares HTML with attributes sorted and JSON with keys sorted, as the crate does, and shows JSON changes by path (`items[3].price: 10 → 12`).
97+
- **Screenshots** carry the crate's platform, `chromium-linux`, `chromium-mac` or `chromium-windows` (`SNAPSHOT_PLATFORM` or `BrowserOptions::platform` sets another), so each platform keeps its own baselines. VisualCI also keeps separate sets for CI and for local runs on a Mac or Linux (see [Local runs](https://visualci.com/docs/local-runs.md#environments)).
98+
- **Ignore rules** given in a test (`.ignoring(["$.created_at", r"ord_[0-9a-z]{24}"])`, rules starting with `$` are JSON paths and the rest regular expressions) go with that snapshot, and VisualCI applies them before comparing. Rules for many snapshots at once go in [`visualci.yml`](https://visualci.com/docs/reference/config.md).
99+
- **`BrowserOptions::threshold(0.1)`** goes with each screenshot as its own threshold, VisualCI's perceptual colour threshold. Whether anti-aliased pixels count follows the project's setting.
100+
101+
For screenshots that don't change on every run (fixed fake data, a frozen clock with `app.travel_to(..)`, no fonts or images from other sites), see [Deterministic screenshots](https://visualci.com/docs/screenshots/deterministic.md).
102+
103+
## Reviewing the changes
104+
105+
When something changed, your coding agent reads it over VisualCI's MCP server (`get_build`, then `get_snapshot`) or with `visualci build show`, checks it against the code, and approves it or fixes the code. See [Coding agents](https://visualci.com/docs/agents.md).
106+
107+
This skill is the page https://visualci.com/docs/snapshots/laravel-rust.md. All of VisualCI's documentation: https://visualci.com/llms.txt

‎skills/visualci/SKILL.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Load the one for the user's CI provider and test tools:
8181
- `visualci-insta`: Send insta snapshot files to VisualCI, so a changed snapshot waits for review instead of failing cargo test.
8282
- `visualci-jenkins`: Send VisualCI builds from a Jenkins pipeline. The CLI reads the commit, branch and pull request from the Git plugin and multibranch pipelines.
8383
- `visualci-jest`: Send Jest snapshot files to VisualCI, so a changed snapshot waits for review instead of failing the build.
84+
- `visualci-laravel-rust`: Screenshot and snapshot tests for Laravel Rust apps with snapshot-testing-laravel, reviewed on VisualCI instead of committed as files.
8485
- `visualci-local-runs`: Run your tests on a laptop against VisualCI's baselines, fail each test once with every snapshot it changed, and approve local changes so CI matches them.
8586
- `visualci-mobile`: Send iOS, Android, React Native and Flutter screenshots to VisualCI, from XCUITest, swift-snapshot-testing, Espresso, Paparazzi, Maestro, Detox and Flutter golden tests.
8687
- `visualci-pdfs`: How VisualCI renders, fingerprints and compares PDFs, page by page, in one pinned environment.

0 commit comments

Comments
 (0)