Couldn't determine Mocha version
gcirone opened this issue · comments
Hi,
I have issue with cypress when the project is stored in a different folder then root, for example:
cypress run --project=apps/site-e2e
Deps installed:
"mocha": "6.1.4",
"mocha-junit-reporter": "1.23.0",
I presume the problem is because the packages json path start with ./
Line 17 in 239e456
In fact just add fs.readFileSync(__dirname + "/../node_modules/mocha/package.json", "utf8")
seems to work, but of course there are many way to aim that.
Is mocha 6.1.4 and mocha-junit-reporter in node_modules in the project folder (apps/site-e2e) and in which dir is your package.json that specifies them?
We could just set a flag that could be passed in, such as mocha6plus, which the user can set, which if set will override the fs check. The warning could state to the user that they can explicitly set the flag?
The package json is on the project root
apps/site-e2e/cypress.json
package.json
But i think the best approach is to make it work without setting any flag, should be transparent for the user.
What do you think about this approach:
const mochaPackageJson = path.dirname(require.resolve('mocha')) + '/package.json';
const { version } = require(mochaPackageJson);
console.log('version', version)
I can open a PR if you wish :)
Agree with you mate, making it as transparent to the user as possible if preferable.
PR would be good, I can open my fork again, pull in the change and publish it as mocha-junit-reporters for testing 👌
Hey @gcirone solution looks good to me. I am not a maintainer of this repository and created mocha-junit-reporters so I could test the changes and allow others to consume it while we were waiting for the mocha 6 compatability fix to be merged into this repository
Released in mocha-junit-reporter@1.23.1 work as expected 🥇