Skip to content

Instantly share code, notes, and snippets.

@joelgriffith
Created July 11, 2017 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelgriffith/42994a33879b85df98071f1e88d1317d to your computer and use it in GitHub Desktop.
Save joelgriffith/42994a33879b85df98071f1e88d1317d to your computer and use it in GitHub Desktop.
Test suite with Navalia and parallelization
const { Navalia } = require('navalia');
const navalia = new Navalia();
describe('My Page', () => {
afterAll(() => {
return navalia.kill();
});
it.concurrent('should have a username input', () => {
return navalia.run((chrome) => chrome.goto('http://localhost:3000/')
.then(() => chrome.exists('[data-test="username"]'))
.then((exists) => expect(exists).toEqual(true)));
});
it.concurrent('should have a password input', () => {
return navalia.run((chrome) => chrome.goto('http://localhost:3000/')
.then(() => chrome.exists('[data-test="password"]'))
.then((exists) => expect(exists).toEqual(true)));
});
it.concurrent('should have a submit button', () => {
return navalia.run((chrome) => chrome.goto('http://localhost:3000/')
.then(() => chrome.exists('[data-test="submit"]'))
.then((exists) => expect(exists).toEqual(true)));
});
it.concurrent('should show an error if no username is filled out', () => {
return navalia.run((chrome) => 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')));
});
it.concurrent('should show a password error if a username is filled but no password', () => {
return navalia.run((chrome) => chrome.goto('http://localhost:3000/')
.then(() => chrome.type('[data-test="username"]', 'joel@joelgriffith.net'))
.then(() => chrome.click('[data-test="submit"]'))
.then(() => chrome.html('[data-test="error"]'))
.then((html) => expect(html).toContain('Password is required')));
});
it.concurrent('dismisses username errors', () => {
return navalia.run((chrome) => chrome.goto('http://localhost:3000/')
.then(() => chrome.click('[data-test="submit"]'))
.then(() => chrome.click('[data-test="error"] button'))
.then(() => chrome.exists('[data-test="error"]'))
.then((errorPersists) => expect(errorPersists).toEqual(false)));
});
it.concurrent('dismisses password errors', () => {
return navalia.run((chrome) => chrome.goto('http://localhost:3000/')
.then(() => chrome.type('[data-test="username"]', 'joel@joelgriffith.net'))
.then(() => chrome.click('[data-test="submit"]'))
.then(() => chrome.click('[data-test="error"] button'))
.then(() => chrome.exists('[data-test="error"]'))
.then((errorPersists) => expect(errorPersists).toEqual(false)));
});
it.concurrent('should show no errors if both username and password are filled out', () => {
return navalia.run((chrome) => chrome.goto('http://localhost:3000/')
.then(() => chrome.type('[data-test="username"]', 'joel@joelgriffith.net'))
.then(() => chrome.type('[data-test="password"]', '1234foobarbaz'))
.then(() => chrome.click('[data-test="submit"]'))
.then(() => chrome.exists('[data-test="error"]'))
.then((errorExists) => expect(errorExists).toEqual(false)));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment