This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('should not have visual regressions', () => { | |
| ...do something to generate an image... | |
| expect(image).toMatchImageSnapshot(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Chrome } = require('navalia'); | |
| const { toMatchImageSnapshot } = require('jest-image-snapshot'); | |
| expect.extend({ toMatchImageSnapshot }); | |
| describe('Visual Regressions', () => { | |
| let chrome = null; | |
| beforeEach(() => { | |
| chrome = new Chrome(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Chrome } = require('navalia'); | |
| describe('My Page', () => { | |
| let chrome = {}; | |
| beforeEach(() => { | |
| chrome = new Chrome(); | |
| }); | |
| afterEach(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // :missingUsername visits a page and immediately clicks submit | |
| // without entering the user's name. It returns the chrome instance | |
| // so you can invoke further actions or assertions! | |
| const missingUsername = (chrome) => | |
| chrome.goto('http://localhost:3000/') | |
| .then(() => chrome.click('[data-test="submit"]')); | |
| // Consume the prior action and assert further behavior | |
| it('should allow users to dismiss errors', () => { | |
| return missingUsername(chrome) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // :missingUsername visits a page and immediately clicks submit | |
| // without entering the user's name. It returns the chrome instance | |
| // so you can invoke further actions or assertions! | |
| const missingUsername = (chrome) => | |
| chrome.goto('http://localhost:3000/') | |
| .then(() => chrome.click('[data-test="submit"]')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Goto a page, click a button, expect a message | |
| it('should show an error if no username is filled out', () => { | |
| return chrome.goto('http://localhost:3000/') | |
| .then(() => chrome.click('[data-test="submit"]')) | |
| .then(() => chrome.html('[data-test="error"]')) | |
| .then((html) => expect(html).toContain('Username is required')); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Chrome } = require('navalia'); | |
| const pageUrl = 'http://localhost:3000/'; | |
| describe('My Page', () => { | |
| let chrome = {}; | |
| // Setup a clean instance for each test | |
| beforeEach(() => { | |
| chrome = new Chrome(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import './App.css'; | |
| class LoginPage extends Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| username: '', | |
| password: '', | |
| error: '', |