Nuxt/examples/jest-puppeteer/test/index.spec.js
awronski 106141f74c feat: jest-puppeteer example (#4163)
* feat: jest-puppeteer example

* - Refactor test

* - lint

* - lint

* - eslint-disable no-undef
2018-10-25 19:44:09 +02:00

33 lines
858 B
JavaScript
Executable File

const devices = require('puppeteer/DeviceDescriptors')
const iPhone = devices['iPhone 6']
const BASE_URL = 'http://127.0.0.1:3000'
describe('Index page', () => {
let page
beforeAll(async () => {
// eslint-disable-next-line no-undef
page = await browser.newPage()
await page.emulate(iPhone)
await page.goto(BASE_URL)
})
afterAll(async () => {
await page.close()
})
it('test index title', async () => {
expect.assertions(1)
const title = await page.evaluate(() => document.title)
expect(title).toMatchSnapshot('index.title')
})
it('test navigation to about page', async () => {
expect.assertions(1)
await page.click('a#about-link')
await page.waitForSelector('p#hello-msg')
const msg = await page.$eval('p#hello-msg', e => e.textContent)
expect(msg).toMatchSnapshot('about.msg')
})
})