Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Let's get visual - Visual testing in your project

Let's get visual - Visual testing in your project

Ramona Schwering

November 24, 2021
Tweet

More Decks by Ramona Schwering

Other Decks in Programming

Transcript

  1. // First: Loading installation script // Run install script ./vrt-install.sh

    // Next: Install Cypress plugin npm install @visual-regression-tracker/agent-cypress
  2. name: CI on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps:

    - name: Checkout uses: actions/[email protected] - name: Install run: yarn - name: Percy Test uses: percy/[email protected] with: command: "cypress run" env: PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
  3. const now = new Date(2018, 1, 1) .getTime(); // freezes

    the system time to Jan 1, 2018 cy.clock(now); // continue with your normal tests below
  4. // Command usage await percySnapshot('Home page', { percyCSS: `iframe {

    display: none; }` }); version: 1 snapshot: percy-css: | iframe { display: none; }
  5. // An own Command Cypress.Commands.add('changeElementStyling', (selector, imageStyle) => { //

    E.g. replace the image with a fixed one cy.get(selector) .invoke('attr', 'style', imageStyle) .should('have.attr', 'style', imageStyle); });