Created
February 22, 2019 10:57
-
-
Save iGitScor/9a9aed338de93e8caca9723a4754fe61 to your computer and use it in GitHub Desktop.
Snapshot
This file contains 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 puppeteer = require('puppeteer'); | |
function pages(page) { | |
return 'http://localhost:8100/#/' + page; | |
} | |
describe('Relayed', () => { | |
let browser; | |
let page; | |
beforeAll(async () => { | |
browser = await puppeteer.launch(); | |
}); | |
beforeEach(async () => { | |
page = await browser.newPage(); | |
await page.setViewport({ isMobile: true, hasTouch: true, height: 640, width: 320 }); | |
}); | |
it('Login', async () => { | |
await page.goto(pages('login')); | |
let image = await page.screenshot({ fullPage: true }); | |
expect(image).toMatchImageSnapshot(); | |
/* Focus */ | |
const emailInput = await page.$('[formcontrolname=email] input'); | |
await emailInput.type('[email protected]'); | |
await emailInput.focus(); | |
image = await page.screenshot({ fullPage: true }); | |
expect(image).toMatchImageSnapshot(); | |
/* Error */ | |
const passwordInput = await page.$('[formcontrolname=password] input'); | |
await passwordInput.type('123'); | |
const form = await page.$('[type=submit]'); | |
await form.click(); | |
image = await page.screenshot({ fullPage: true }); | |
expect(image).toMatchImageSnapshot(); | |
}); | |
it('Dashboard', async () => { | |
await page.goto(pages('dashboard')); | |
const image = await page.screenshot({ fullPage: true }); | |
expect(image).toMatchImageSnapshot(); | |
}); | |
afterAll(async () => { | |
await browser.close(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment