Open yuriyKazan opened 7 years ago
yeah this could be better
We should probably just replace require
in all the try-catches with require.resolve
and do the actual require
outside of try-catch, so we can still give an error if all the require.resolve
s fail (could update from 'invalid reporter <reporter>'
to 'no reporter "<reporter>" found'
) but if the reporter is there but not loadable the original error is still thrown.
SR: 1) Use the npm to install third-party reporter (e.g. myReporter). 2) Modify the reporter by adding a module (e.g. "diff = require('diff')") into myReporter.js file. 3) Try to run the mocha with the report.
ER: Appears correct error message (e.g. Error: Cannot find module 'diff'). AR: Appears error message:
I reported the issue here in case if someone also will encounter the problem.