Skip to content

Commit

Permalink
fix: wait for runner to me in the global scope inside workers
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Apr 8, 2021
1 parent 83ab7d1 commit 7de86a4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
"@hd-forks/v8-to-istanbul": "7.1.1",
"camelcase": "^6.2.0",
"esbuild": "^0.11.5",
"fresh-tape": "^5.1.1",
"globby": "^11.0.3",
"kleur": "^4.1.4",
"lilconfig": "^2.0.2",
"lodash": "^4.17.21",
"merge-options": "^3.0.4",
"ora": "^5.4.0",
"p-wait-for": "3.2.0",
"path-browserify": "^1.0.1",
"playwright-core": "1.10.0",
"polka": "^0.5.2",
Expand All @@ -63,7 +65,6 @@
"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 Down
3 changes: 3 additions & 0 deletions src/runner-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const merge = require('merge-options')
const Runner = require('./runner')
const waitFor = require('p-wait-for')
const { build } = require('./utils')

const runMocha = () => `
Expand Down Expand Up @@ -54,6 +55,8 @@ class MochaRunner extends Runner {
}
case 'worker': {
const worker = await page.waitForEvent('worker')
// @ts-ignore
await waitFor(() => worker.evaluate(() => self.mocha !== undefined))
await worker.evaluate(runMochaWorker())
break
}
Expand Down
3 changes: 3 additions & 0 deletions src/runner-zora.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const path = require('path')
const Runner = require('./runner')
const waitFor = require('p-wait-for')
const { build } = require('./utils')

const runZora = () => `
Expand Down Expand Up @@ -38,6 +39,8 @@ class ZoraRunner extends Runner {
}
case 'worker': {
const worker = await page.waitForEvent('worker')
// @ts-ignore
await waitFor(() => worker.evaluate(() => self.zora !== undefined))
await worker.evaluate(runZoraWorker())
break
}
Expand Down
30 changes: 20 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2295,6 +2295,11 @@ ora@^5.4.0:
strip-ansi "^6.0.0"
wcwidth "^1.0.1"

p-finally@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=

p-limit@^1.1.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8"
Expand Down Expand Up @@ -2344,6 +2349,13 @@ p-map@^4.0.0:
dependencies:
aggregate-error "^3.0.0"

p-timeout@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-3.2.0.tgz#c7e17abc971d2a7962ef83626b35d635acf23dfe"
integrity sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==
dependencies:
p-finally "^1.0.0"

p-try@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
Expand All @@ -2354,6 +2366,13 @@ p-try@^2.0.0:
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==

p-wait-for@3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/p-wait-for/-/p-wait-for-3.2.0.tgz#640429bcabf3b0dd9f492c31539c5718cb6a3f1f"
integrity sha512-wpgERjNkLrBiFmkMEjuZJEWKKDrNfHCKA1OhyN1wg1FrLkULbviEy6py1AyJUgZ72YWFbZ38FIpnqvVqAlDUwA==
dependencies:
p-timeout "^3.0.0"

parent-module@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
Expand Down Expand Up @@ -2621,16 +2640,7 @@ readable-stream@2.2.9:
string_decoder "~1.0.0"
util-deprecate "~1.0.1"

readable-stream@^3.4.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198"
integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==
dependencies:
inherits "^2.0.3"
string_decoder "^1.1.1"
util-deprecate "^1.0.1"

"readable-stream@https://registry.npmjs.org/@leichtgewicht/readable-stream/-/readable-stream-3.6.0.tgz":
readable-stream@^3.4.0, "readable-stream@https://registry.npmjs.org/@leichtgewicht/readable-stream/-/readable-stream-3.6.0.tgz":
version "3.6.0"
uid "25682c94346526abc8c8b1ece125b52a7247bb2e"
resolved "https://registry.npmjs.org/@leichtgewicht/readable-stream/-/readable-stream-3.6.0.tgz#25682c94346526abc8c8b1ece125b52a7247bb2e"
Expand Down

0 comments on commit 7de86a4

Please sign in to comment.