Skip to content

Commit

Permalink
fix: Wait for child process to be ready (#19792)
Browse files Browse the repository at this point in the history
Co-authored-by: Zach Bloomquist <github@chary.us>
Co-authored-by: Zach Bloomquist <git@chary.us>
  • Loading branch information
3 people committed Feb 17, 2022
1 parent 0d3e645 commit ad50062
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions packages/server/lib/plugins/child/run_plugins.js
Expand Up @@ -212,6 +212,8 @@ const runPlugins = (ipc, pluginsFile, projectRoot) => {
ipc.on('execute', (event, ids, args) => {
execute(ipc, event, ids, args)
})

ipc.send('ready')
}

// for testing purposes
Expand Down
4 changes: 3 additions & 1 deletion packages/server/lib/plugins/index.js
Expand Up @@ -139,7 +139,9 @@ const init = (config, options) => {
Object.keys(config).sort().forEach((key) => orderedConfig[key] = config[key])
config = orderedConfig

ipc.send('load', config)
ipc.on('ready', () => {
ipc.send('load', config)
})

ipc.on('loaded', (newCfg, registrations) => {
_.omit(config, 'projectRoot', 'configFile')
Expand Down
18 changes: 11 additions & 7 deletions packages/server/test/unit/plugins/index_spec.js
Expand Up @@ -115,15 +115,19 @@ describe('lib/plugins/index', () => {
})
})

it('sends \'load\' event with config via ipc', () => {
ipc.on.withArgs('loaded').yields([])
it('sends \'load\' event with config via ipc once it receives \'ready\'', () => {
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

3 comments on commit ad50062

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ad50062 Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.1/linux-x64/circle-develop-ad50062ca21aefbfe54142d4b76eec25c579b6de/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ad50062 Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.1/win32-x64/circle-develop-ad50062ca21aefbfe54142d4b76eec25c579b6de/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ad50062 Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.1/darwin-x64/circle-develop-ad50062ca21aefbfe54142d4b76eec25c579b6de/cypress.tgz

Please sign in to comment.