Skip to content

Commit

Permalink
Test for async ready event
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Feb 15, 2022
1 parent 0f14ba7 commit 0fc9928
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/server/test/unit/plugins/index_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,18 @@ describe('lib/plugins/index', () => {
})

it('sends \'load\' event with config via ipc once it receives \'ready\'', () => {
ipc.on.withArgs('ready').yields([])
ipc.on.withArgs('loaded').yields([])
const config = { pluginsFile: 'cypress-plugin', testingType: 'e2e' }

return plugins.init(config, getOptions({ testingType: 'e2e' })).then(() => {
expect(ipc.send).to.be.calledWith('load', {
...config,
...configExtras,
})
plugins.init(config, getOptions({ testingType: 'e2e' }))

expect(ipc.send).to.not.be.called

// simulate async ready event
ipc.on.withArgs('ready').firstCall.callback()

expect(ipc.send).to.be.calledWith('load', {
...config,
...configExtras,
})
})

Expand Down

0 comments on commit 0fc9928

Please sign in to comment.