This issue happens in Cypress v5.0.0 and does not occur in v4.12.1
If you try to run Cypress tests in https://github.com/eggheadio/egghead-next then a curious thing happens: it pops a new Cypress instance while trying to bundle.
Recording: https://jumpshare.com/v/v5mfJi5QlSbsd7IpBFAb
I have the same problem in cypress v5.0.2. It always opens multiple windows but never it run the tests.
Narrowed it down to these dependencies
"dependencies": {
"next": "^9.5.3"
},
"devDependencies": {
"cypress": "5.2.0",
"jest": "^26.4.2"
}
and .babelrc file
{
"presets": ["next/babel"],
"plugins": ["istanbul"]
}
$ npm ls babel-plugin-istanbul
[email protected] /Users/gleb/git/egghead-next
โโโฌ [email protected]
โโโฌ @jest/[email protected]
โโโฌ @jest/[email protected]
โ โโโ [email protected]
โโโฌ [email protected]
โโโฌ [email protected]
โโโ [email protected] deduped
Top level dependencies
$ npm ls --depth 0
[email protected] /Users/gleb/git/egghead-next
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ UNMET PEER DEPENDENCY react@^16.6.0
โโโ UNMET PEER DEPENDENCY react-dom@^16.6.0
Behavior: when you click on the spec.js it opens second global instance of Cypress

Reproducible example in https://github.com/cypress-io/cypress-test-tiny/tree/open-global
See the second instance of Cypress open!
Relevant portion of the debug log
cypress:server:cypress starting cypress with argv [ '/Users/gleb/Library/Caches/Cypress/5.2.0/Cypress.app/Contents/MacOS/Cypress', '/Users/gleb/git/cypress-test-tiny/node_modules/babel-plugin-istanbul/lib/load-nyc-config-sync.js', '/Users/gleb/git/cypress-test-tiny' ] +0ms
cypress:server:args argv array: [ '/Users/gleb/Library/Caches/Cypress/5.2.0/Cypress.app/Contents/MacOS/Cypress', '/Users/gleb/git/cypress-test-tiny/node_modules/babel-plugin-istanbul/lib/load-nyc-config-sync.js', '/Users/gleb/git/cypress-test-tiny' ] +0ms
cypress:server:args argv parsed: { _: [ '/Users/gleb/Library/Caches/Cypress/5.2.0/Cypress.app/Contents/MacOS/Cypress', '/Users/gleb/git/cypress-test-tiny/node_modules/babel-plugin-istanbul/lib/load-nyc-config-sync.js', '/Users/gleb/git/cypress-test-tiny' ], invokedFromCli: false, cwd: '/Users/gleb/Library/Caches/Cypress/5.2.0/Cypress.app/Contents/Resources/app/packages/server' }
Traced it inside babel-plugin-istanbul to the function that loads the config like this
function loadNycConfig(cwd, opts) {
...
const result = JSON.parse((0, _child_process.execFileSync)(process.execPath, args));
...
return config;
}
Which in our case starts Cypress pointing at the args! For example if we print the args
console.log('about to execute')
console.log(process.execPath, args.join(' '))
we get
about to execute
/Users/gleb/Library/Caches/Cypress/5.2.0/Cypress.app/Contents/MacOS/Cypress
/Users/gleb/git/cypress-test-tiny/node_modules/babel-plugin-istanbul/lib/load-nyc-config-sync.js
/Users/gleb/git/cypress-test-tiny
Because it thinks it is executing inside Node, thus uses exec process to load other scripts as child processes. Should we separate every bundler better into a child process to solve this - because this one executes a child process _inside a require_.
Note: using system Node is NOT a workaround. The setting below still opens Cypress while loading babel options
{
"nodeVersion": "system"
}
Is there any movement on this? Kinda waiting on it so we can switch back to v5...
@johnlindquist I'm planning to look into this sometime in the next few days. Sorry for the inconvenience!
@chrisbreiding thanks for looking into this. I'm getting the same issue using TS and Parcel without any explicit babel-plugin-istanbul. I'm also using route2, so I can't go back to 4.x.
@bahmutov: Should we separate every bundler better into a child process to solve this - because this one executes a child process inside a require.
That's exactly what we need to do. We do this for user-registered preprocessors, but when the user has not registered a preprocessor, we register our own default preprocessor _in the main Cypress process_. I'm fixing this in #8826 by now registering the default preprocessor in the plugins child process as well.
๐ ๐ ๐
Sent from my iPhone
On Oct 13, 2020, at 12:02, Chris Breiding notifications@github.com wrote:
๏ปฟ
@bahmutov: Should we separate every bundler better into a child process to solve this - because this one executes a child process inside a require.That's exactly what we need to do. We do this for user-registered preprocessors, but when the user has not registered a preprocessor, we register our own default preprocessor in the main Cypress process. I'm fixing this in #8826 by now registering the default preprocessor in the plugins child process as well.
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
The code for this is done in cypress-io/cypress#8826, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Released in 5.4.0.
This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.4.0, please open a new issue.
Most helpful comment
@johnlindquist I'm planning to look into this sometime in the next few days. Sorry for the inconvenience!