Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move fresh-tape to deps #173

Merged
merged 2 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"sirv": "^1.0.11",
"source-map": "0.6.1",
"strip-ansi": "^6.0.0",
"fresh-tape": "^5.1.1",
"tempy": "^1.0.1",
"test-exclude": "^6.0.0"
},
Expand All @@ -75,10 +76,8 @@
"debug": "^4.3.1",
"delay": "^5.0.0",
"execa": "^5.0.0",
"fresh-tape": "^5.1.1",
"hd-scripts": "^0.1.1",
"mocha": "^8.3.2",
"np": "^7.3.0",
"tap-spec": "^5.0.0",
"uvu": "^0.5.1",
"zora": "^4.0.2"
Expand Down
46 changes: 25 additions & 21 deletions src/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,35 +220,21 @@ class Runner {
}
}

/**
* Wait for tests to finish
*
* @param {Page} page
*/
async waitForTestsToEnd(page) {
await page.waitForFunction(
// @ts-ignore
() => self.PW_TEST.ended === true,
undefined,
{
timeout: 0,
polling: 100, // need to be polling raf doesnt work in extensions
}
)
const testsFailed = await page.evaluate('self.PW_TEST.failed')

await this.stop(testsFailed)
}

async run() {
let spinner = ora('Setting up browser').start()

try {
// get the context
const context = await this.launch()

// run the before script
if (this.options.before) {
await this.runBefore(context)
}

// get the page
const page = await this.setupPage(context)

// uncaught rejections
page.on('pageerror', (err) => {
console.error(err)
Expand All @@ -259,9 +245,12 @@ class Runner {
})
spinner.succeed('Browser setup')

// bundle tests
spinner = ora('Bundling tests').start()
const file = await this.compiler()
spinner.succeed()

// run tests
await this.runTests(page, file)

// Re run on page reload
Expand All @@ -270,10 +259,25 @@ class Runner {
await this.runTests(page, file)
})
} else {
await this.waitForTestsToEnd(page)
// wait for the tests
await page.waitForFunction(
// @ts-ignore
() => self.PW_TEST.ended === true,
undefined,
{
timeout: 0,
polling: 100, // need to be polling raf doesnt work in extensions
}
)
const testsFailed = await page.evaluate('self.PW_TEST.failed')

// coverage
if (this.options.cov && page.coverage) {
await createCov(this, await page.coverage.stopJSCoverage(), file)
}

// exit
await this.stop(testsFailed)
}
} catch (err) {
spinner.fail('Running tests failed.')
Expand Down