# Cypress

> Send Cypress screenshots to VisualCI, with a baseline per browser and a threshold for anti-aliasing.

Source: https://visualci.com/docs/screenshots/cypress/
All of VisualCI's documentation: https://visualci.com/llms.txt

Take screenshots in your tests with names:

```js
it('signup form', () => {
  cy.visit('/signup')
  cy.screenshot('signup_form', { capture: 'fullPage' })
})
```

Cypress saves them under `cypress/screenshots/<spec file>/`, and the path becomes the snapshot's name. Turn off the screenshots Cypress takes when a test fails, so they aren't sent as snapshots:

```js
// cypress.config.js
module.exports = { screenshotOnRunFailure: false }
```

Then upload after the run:

```sh
export VISUALCI_BUILD_ID=$(visualci build create)
npx cypress run --browser chrome
visualci upload --platform chrome-linux --threshold 0.1 cypress/screenshots
visualci build finalize
```

Cypress deletes `cypress/screenshots` before each run, so the directory holds only this run's screenshots.
