I am using cypress. But as I understand the cypress is built above mocha. So, I want to check what mocha version the project I am working with uses. I am heading to the package.json
doing the search, but finding no mocha dependencies. Does it mean that mocha is built into cypress? How could I determine the used inside cypress mocha version then?
Updated
As Drew pointed out there are many versions of Mocha used in various packages under the Cypress repository.
I'm not sure that dependencies
vs devDependencies
is a solid indicator, since Cypress uses the Mocha library to make a modified version.
Here's a sampling from packages in the Cypress 12.16.0 repo:
so it kind of depends on the part of the Cypress suite you are using (Component tester, e2e runner, module api)
The link I would use for e2e testing is the driver package
"devDependencies": { ... "mocha": "7.0.1",
Another approach that currently works is querying the global Cypress
object.
it('log the Mocha version in use', function() {
console.log(Cypress.mocha._mocha.version) // 7.0.1 for Cypress 12.16.0
})
where Cypress.mocha
is the instance object and Cypress.mocha._mocha
is the class definition (shown in devtools as Mocha
type).
These properties may be removed at a future time.