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 chrome = new Chrome(); | |
chrome.goto('https://www.google.com') | |
.then(() => chrome.done()); |
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 chrome = new Chrome(); | |
async function interactWithSearch() { | |
await chrome.goto('https://joelgriffith.github.io/navalia/'); | |
await chrome.focus('#search-input'); | |
await chrome.type('#search-input', 'coverage'); | |
return chrome.done(); | |
} | |
interactWithSearch(); |
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: '', |
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
// 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
// :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
// :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
const { Chrome } = require('navalia'); | |
describe('My Page', () => { | |
let chrome = {}; | |
beforeEach(() => { | |
chrome = new Chrome(); | |
}); | |
afterEach(() => { |