Skip to content

Commit

Permalink
tests: Add more feature to browser helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Nov 2, 2017
1 parent 8015a29 commit c533ff9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 83 deletions.
80 changes: 0 additions & 80 deletions test/children.path.test.js

This file was deleted.

15 changes: 12 additions & 3 deletions test/helpers/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import puppeteer from 'puppeteer'

let browser = null

export async function start() {
export async function start(options = {}) {
// https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
browser = await puppeteer.launch({
browser = await puppeteer.launch(Object.assign({
args: ['--no-sandbox', '--disable-setuid-sandbox']
})
}, options))
}

export async function stop() {
Expand All @@ -21,6 +21,7 @@ export async function page(url) {
await page.waitForFunction('!!window.$nuxt')
page.html = () => page.evaluate(() => window.document.documentElement.outerHTML)
page.$text = (selector) => page.$eval(selector, (el) => el.textContent)
page.$$text = (selector) => page.$$eval(selector, (els) => els.map((el) => el.textContent))
page.$nuxt = await page.evaluateHandle('window.$nuxt')

page.nuxt = {
Expand All @@ -30,6 +31,14 @@ export async function page(url) {
await this.waitForNavigation()
}
},
routeData() {
return page.evaluate(($nuxt) => {
return {
path: $nuxt.$route.path,
query: $nuxt.$route.query
}
}, page.$nuxt)
},
loadingData() {
return page.evaluate(($nuxt) => $nuxt.$loading.$data, page.$nuxt)
},
Expand Down

0 comments on commit c533ff9

Please sign in to comment.