Cypress Image Diff Documentation
  • Migrate from v1 to v2
  • Getting started
    • Cypress integration
      • Typescript
      • Javascript
      • Browserstack
      • Cypress < v10
    • cy.compareSnapshot command
    • Custom config file
      • ROOT_DIR
      • FAILURE_THRESHOLD
      • RETRY_OPTIONS
      • FAIL_ON_MISSING_BASELINE
      • COMPARISON_OPTIONS
      • JSON_REPORT
      • CYPRESS_SCREENSHOT_OPTIONS
      • REPORT_DIR
      • SCREENSHOTS_DIR
      • NAME_TEMPLATE
    • Reporting
      • JSON report
      • Cypress Image Diff HTML Report
      • Legacy HTML Report
    • Client options
    • Running tests
    • Contributing
    • Publishing
Powered by GitBook
On this page
  1. Getting started
  2. Custom config file

NAME_TEMPLATE

The snapshot naming pattern using replaceable labels. All possible labels are:

  • specName: The spec file name

  • givenName: The name value in cy.compareSnapshot

  • browserName: Short browser name currently running the tests

  • width: Width in pixels for the application under tests' viewport

  • height: Height in pixels for the application under tests' viewport

Any label in square brackets is replaced with its actual value during runtime.

💢 Default value: undefined

// cypress-image-diff.config.js
const config = {
  NAME_TEMPLATE: '[browserName]/[specName]-[givenName]'
};

module.exports = config;

// home-page.cy.js
cy.compareSnapshot('top-banner')

Computed name that is passed to cy.screenshot:

// presumably the browserName is chrome
chrome/home-page.cy-top-banner

Output directory:

.
├── baseline
    ├── chrome
        ├── home-page.cy-top-banner.png
├── comparison
    ├── chrome
        ├── home-page.cy-top-banner.png
├── diff
    ├── chrome
        ├── home-page.cy-top-banner.png
PreviousSCREENSHOTS_DIRNextReporting

Last updated 9 months ago