Couldn't determine Mocha version

See original GitHub issue

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 ./

https://github.com/michaelleeallen/mocha-junit-reporter/blob/239e456f3f73e5abf3ad28f93be96a9b8795a9b9/index.js#L17

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
gcironecommented, Jul 3, 2019

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 😃

0reactions
gcironecommented, Jul 19, 2019

Released in mocha-junit-reporter@1.23.1 work as expected 🥇

Read more comments on GitHub >

github_iconTop Results From Across the Web

Couldn't determine Mocha version · Issue #4602 - GitHub
Current behavior: Couldn't determine Mocha version This has been printing at the beginning of my test since the upgrade to 3.3.2.
Read more >
No Mocha version is shown in the package.json when testing ...
I am heading to the package.json doing the search, but finding no mocha dependencies. Does it mean that mocha is built into cypress?...
Read more >
Couldn't determine Mocha version - Bountysource
Current behavior: Couldn't determine Mocha version. This has been printing at the beginning of my test since the upgrade to 3.3.2.
Read more >
mocha-spec-json-reporter-2 - npm package - Snyk
Unable to detect license. We couldn't find an appropriate license for this project. It is highly advised to make sure the project license...
Read more >
Reporters | Cypress Documentation
History. Version, Changes. 4.4.2, Custom Mocha reporters updated to use the version of Mocha bundled with Cypress. No ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found