Skip to content
Permalink
7b00c58f45
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
62 lines (45 sloc) 1.59 KB
'use strict'
const puppeteer = require('puppeteer')
const { configureToMatchImageSnapshot } = require('jest-image-snapshot')
const width = 800
const height = 600
const delayMS = 0
const shell = require('shelljs')
let browser
let page
// threshold is the difference in pixels before the snapshots dont match
const toMatchImageSnapshot = configureToMatchImageSnapshot({
customDiffConfig: { threshold: 2 },
noColors: true,
})
expect.extend({ toMatchImageSnapshot })
beforeAll( async() => {
browser = await puppeteer.launch({ headless: false, slowMo: delayMS, args: [`--window-size=${width},${height}`] })
page = await browser.newPage()
await page.setViewport({ width, height })
})
beforeEach( () => shell.exec('./abolishDB.sh'))
afterAll( () => browser.close() )
describe('menu', () => {
test('Main Menu', async done => {
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' })
await page.goto('http://localhost:8080/login', { timeout: 30000, waitUntil: 'load' })
await page.click('[href="/register"]')
await page.type('input[name=user]', 'Craig')
await page.type('input[name=pass]', 'bread')
await page.waitFor(1000)
await page.click('input[type=submit]')
await page.waitFor(1000)
let title = await page.title()
expect(title).toBe('Log In')
await page.type('input[name=user]', 'Craig')
await page.type('input[name=pass]', 'bread')
await page.click('input[type=submit]')
title = await page.title()
expect(title).toBe('Main Menu')
await page.click('button[name=Menu]')
title = await page.title()
expect(title).toBe('Main Menu')
done()
})
})