test: improve e2e test stability

This commit is contained in:
Evan You 2021-03-01 10:49:23 -05:00
parent 34f354b2a0
commit 24b35237a0

View File

@ -28,10 +28,17 @@ export function setupPuppeteer() {
let browser: puppeteer.Browser
let page: puppeteer.Page
beforeEach(async () => {
beforeAll(async () => {
browser = await puppeteer.launch(puppeteerOptions)
})
beforeEach(async () => {
page = await browser.newPage()
await page.evaluateOnNewDocument(() => {
localStorage.clear()
})
page.on('console', e => {
if (e.type() === 'error') {
const err = e.args()[0] as any
@ -44,6 +51,10 @@ export function setupPuppeteer() {
})
afterEach(async () => {
await page.close()
})
afterAll(async () => {
await browser.close()
})