Skip to content

Commit

Permalink
fix: test async callback more (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov authored May 3, 2024
1 parent 5476a7e commit 5ad0352
Show file tree
Hide file tree
Showing 4 changed files with 419 additions and 127 deletions.
5 changes: 5 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = defineConfig({
video: false,
setupNodeEvents(cypressOn, config) {
const on = require('.')(cypressOn)

on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome') {
launchOptions.args.push('--window-size=1366,768')
Expand All @@ -29,6 +30,10 @@ module.exports = defineConfig({
on('after:spec', (a) => {
console.log('after spec 3', a.relative)
})

on('after:run', async () => {
console.log('after run async callback')
})
},
},
})
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ function onProxy(on) {
// support async callbacks
for (let fn of listeners[eventName]) {
result = await fn.apply(null, arguments)
debug(
'event %s, applied callback %s',
eventName,
fn.name || 'anonymous',
)
}
// return the last result
return result
Expand Down
Loading

0 comments on commit 5ad0352

Please sign in to comment.