visualci.yml
visualci.yml at the root of your repository holds the project's settings in code. visualci build create finds it, checks it and sends it with the build. Each build uses its own commit's file, so a change to it in a pull request applies to that pull request's builds, and reaches the default branch when the pull request merges.
# yaml-language-server: $schema=https://visualci.com/visualci.schema.json
project: acme/web
ignore:
- snapshots: "api/invoices/**"
json_paths: ["$.generated_at", "$.items[*].id"]
- snapshots: "api/**/request_log.json"
json_paths: ["$..request_id"]
- snapshots: "emails/*.html"
text_patterns: ['Sent \d{4}-\d{2}-\d{2}']
- snapshots: "ios/**"
region: { bottom: 150 }
threshold:
"screenshots/**": 0.1
"pdfs/**": 0
pdf:
engine: pdfbox
dpi: 140
ci_mode: review
uploads:
- path: spec/artifacts
- path: src
from: auto
The CLI looks for visualci.yml, .visualci.yml, visualci.yaml or .visualci.yaml, from the working directory up to the repository's root. VISUALCI_CONFIG names a file somewhere else. An invalid file stops build create with the error, so a build never runs with settings you didn't mean.
Where settings come from
- A field in the file wins for that build.
- A field the file leaves out comes from the project's Settings tab (or
update_projectover MCP). - A setting on one snapshot (
--threshold,--engine, a test'signore) wins over both.
The build's page shows the file it was sent, and get_build returns it as config. A text snapshot's page lists the ignore rules applied to it and where each came from.
Fields
| Field | What it does |
|---|---|
project |
organization/project. The token decides the project; the CLI warns when this names a different one. |
ignore |
What changes on every run: values in text snapshots, and areas of screenshots and pages. A list of rules; see below. When the file has ignore, the project's own rules aren't used. |
threshold |
0 compares exactly; above 0 it's a colour threshold. One number for every snapshot, or a map of snapshot globs to thresholds. When several globs match, the longest glob (by its length in characters) wins. |
pdf.engine |
pdfbox or mutool. |
pdf.dpi |
Render resolution, 36 to 600. |
ci_mode |
review, wait or strict. The file can only make the project's mode stricter (in that order); a looser value is ignored, with a warning on the build. See GitLab CI. |
group_depth |
Large suites: how many leading path segments of a snapshot's name make its group, for runs checked by group (500 or more snapshots). By default, all but the last two. See Large suites. |
uploads |
What a bare visualci upload sends: a list of path (relative to the file), with optional from (jest, vitest, insta, syrupy, rspec or auto), prefix and format. |
gallery |
Screenshots to publish at public URLs, in groups: groups is a list of name, an optional title, and include (snapshot globs); environment names the environment it shows (default ci; see Publish from your laptop). Nothing is public unless a group includes it and the project's gallery is on (a new project's starts off). See Public gallery. |
Unknown fields are errors, so a misspelt field doesn't pass unnoticed.
Ignore rules
Each rule names the snapshots it applies to with snapshots, a glob over snapshot names as VisualCI shows them. Those names leave out the directory you uploaded: visualci upload api (or uploads: [{path: api}]) sends api/invoices/show.json as invoices/show, so its rule is snapshots: "invoices/**", not "api/invoices/**". visualci config check warns about a rule that matches none of the files under uploads, and a build lists any rule that matched none of its snapshots. There are no global rules: a rule without snapshots is an error. Use "**" when a rule really is for every snapshot.
*matches within one segment of the name and**across segments:api/*/log.jsonmatchesapi/users/log.json, andapi/**matches everything underapi/.json_pathsreplace values in JSON snapshots:$.generated_at,$.items[*].id,$..request_id(that key at any depth),$["odd key"].text_patternsare regular expressions, matched in every text format after normalizing.
Matching values become [ignored] on both sides before comparing. A new rule takes effect on the next build, without approving the baseline again.
Masking part of an image
For screenshots and PDF pages, a rule can leave areas of the image out of the diff instead:
ignore:
- snapshots: "ios/**"
region: { bottom: 150 } # the bottom 150 px: a tab bar that renders a little differently each run
- snapshots: "screenshots/app/**"
rects: [{ x: 0, y: 0, width: 300, height: 40 }]
regionmasks bands along the image's edges, each this many pixels deep:top,bottom,leftandright, one or more of them.{ bottom: 150 }stays at the bottom of a screenshot of any height.rectsmasks rectangles, from the image's top-left corner:x,y,widthandheight.- Sizes are in pixels of the image as uploaded (for a PDF, the rendered page at its DPI): a 3x screenshot's 150 px is 50 points.
Pixels inside a masked area aren't compared. A page that differs only inside them is masked and its snapshot unchanged; a change partly outside is reported by the regions outside alone. The review page hatches the masked areas over the images and the diff, get_snapshot lists them per page as masked (with masked_pixels, the differing pixels they hid), and the pull request comment says how many areas of each image it shows were masked. Masks are applied when VisualCI compares, so a new mask takes effect on the next build without approving the baseline again. A rule can combine a mask with json_paths or text_patterns; each part applies to the snapshots it fits. At most 100 regions and rectangles in all.
Mask only what really varies from run to run. A masked area hides every change in it, real ones too.
Rules can also be set next to the assertion, for one snapshot only. The Ruby helpers take ignore:, and an upload manifest entry takes "ignore": {"json_paths": [...], "text_patterns": [...]}.
Changes to the file are reviewed
The file can change what counts as a change, so a pull request can't use it to let changes through unseen. When a build's ignore rules or thresholds could hide something its base build's would show (a new or wider rule, a new masked area, a higher threshold), the build gets a visualci.yml item next to its snapshots. It shows the rules and thresholds before and after, and it has to be approved like any other change. Removing rules or lowering a threshold needs no review.
Checking the file
visualci config check # exits 1 and prints the problem when the file is invalid
visualci config schema # prints the JSON Schema
The schema is also at visualci.com/visualci.schema.json. Editors with the YAML language server validate the file and complete its fields when it starts with the # yaml-language-server comment above.