[FilterSuite plugin] Do not modify prototype of Mocha.Runner
File https://gitlab.open-xchange.com/frontend/codecept-helpers/-/blob/master/src/plugins/filterSuite/index.js contains code that overwrites the method Runner.prototype.run
of Mocha. However, if the host project has installed a different version of Mocha than used by CodeceptJS (e.g. for running unit tests), this patch will have no effect.
Example:
- Host has installed mocha@^8.3.0 which will be installed in
node_modules/mocha
. - Host has installed codeceptjs@^7 which will be installed in
node_modules/codeceptjs
. - CodeceptJS installs the exact version mocha@8.1.3 for itself which will go into
node_modules/codeceptjs/node_modules/mocha
because it does not match with the top-level version. - FilterPlugin does
require('mocha/lib/runner')
which will return top-level mocha@8.3.0, and changes theRunner
prototype. - CodeceptJS uses its own mocha@8.1.3 to run the tests, the patched
Runner
method will not be called.