Skip to content

Commit

Permalink
Tweak puppeteer script.
Browse files Browse the repository at this point in the history
  • Loading branch information
ghinda committed Sep 24, 2024
1 parent 8f721d1 commit 58d8506
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions test/test-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,24 @@ function run () {

puppeteer
.launch(options)
.then(browser => browser.pages()
.then(pages => pages.pop())
.then(page => {
page.on('console', handleConsole)
page.on('dialog', dialog => dialog.dismiss())
page.on('pageerror', err => console.error(err))

return page.evaluateOnNewDocument(initMocha)
.then(() => page.goto(url))
.then(() => page.waitForFunction(() => window.__mochaResult__, { timeout }))
.then(() => page.evaluate(() => window.__mochaResult__))
.then(obj => {
browser.close()
return obj
.then(browser => {
return browser.pages()
.then(pages => pages.pop())
.then(page => {
page.on('console', handleConsole)
page.on('dialog', dialog => dialog.dismiss())
page.on('pageerror', err => console.error(err))

return page.evaluateOnNewDocument(initMocha)
.then(() => page.goto(url))
.then(() => page.waitForFunction(() => window.__mochaResult__, { timeout }))
.then(() => page.evaluate(() => window.__mochaResult__))
.then(obj => {
browser.close()
return obj
})
})
}))
})
}

run()

0 comments on commit 58d8506

Please sign in to comment.