Skip to content

Instantly share code, notes, and snippets.

View randalvance's full-sized avatar
🎮
Focusing

Randal Vance Cunanan randalvance

🎮
Focusing
View GitHub Profile
@randalvance
randalvance / barChart.spec.js
Created February 16, 2020 06:16
Medium Article - React Visual Testing with Cypress
/* eslint-disable no-undef */
/// <reference types="cypress" />
describe('Bar Chart Tests', function() {
it('Should match image snapshot', function() {
cy.visit('http://localhost:3000');
cy.get('.bar-chart').matchImageSnapshot('barChart');
});
});
@randalvance
randalvance / commands.js
Created February 16, 2020 06:01
Medium Article - React Visual Testing with Cypress
/// <reference types="cypress" />
import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
addMatchImageSnapshotCommand();
@randalvance
randalvance / index.js
Created February 16, 2020 05:44
Medium Article - React Visual Testing with Cypress
const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin');
module.exports = (on, config) => {
addMatchImageSnapshotPlugin(on, config);
};
describe('UI Tests', function() {
it('should navigate to Success Page after submitting.',function(){
// first visit the site
cy.visit('http://localhost:3000');
// get elements we will be
// interacting with and alias them
cy.get('input[name="firstName"]').as('firstNameText');
cy.get('input[name="lastName"]').as('lastNameText');
cy.get('select[name="gender"]').as('genderSelect');
cy.get('input[name="areYouAwesome"]')