Open bericp1 opened 3 years ago
Hi Brandon, thanks for the positive feedback and for the junit reporter workaround!
Le mar. 21 sept. 2021 à 14:58, Brandon Phillips @.***> a écrit :
Hey all! Firstly, thanks for the helpful util!
One note though is that in its current form, extendReporterWithFullErrors is incompatible with the popular mocha-junit-reporter https://www.npmjs.com/package/mocha-junit-reporter. Since extendReporterWithFullErrors calls superReporter.call(this, runner, options); before calling withFullErrors, the JUnit reporter attaches its fail handler first which serializes the error to a string for the later-generated XML before addFullErrorIfMeaningful is ever called to modify error.stack.
I fixed this by adding the fail handler before calling the JUnit constructor:
junitWithFullErrors.js:
const { inherits } = require('util');const addFullErrorIfMeaningful = require('mocha-error-reporters/lib/addFullErrorIfMeaningful');const JUnitReporter = require('mocha-junit-reporter'); function JUnitReporterWithFullErrors(runner, options) { //
mocha-error-reporters
has aextendReporterWithFullErrors
util but we manually pull in //addFullErrorIfMeaningful
and extend the JUnit reporter in order to ensure that our //.on('fail', ...)
is called before JUnit's.on('fail', ...
so that the full error data is // appended toerror.stack
before JUnit serializes it to XML. runner.on('fail', (test, error) => addFullErrorIfMeaningful(error)); JUnitReporter.call(this, runner, options);}inherits(JUnitReporterWithFullErrors, JUnitReporter); module.exports = JUnitReporterWithFullErrors;— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/VilledeMontreal/mocha-error-reporters/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6M4XZRM6NN234POM2XIELUDDIWFANCNFSM5EPLNUOA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Hey all! Firstly, thanks for the helpful util!
One note though is that in its current form,
extendReporterWithFullErrors
is incompatible with the popularmocha-junit-reporter
. SinceextendReporterWithFullErrors
callssuperReporter.call(this, runner, options);
before callingwithFullErrors
, the JUnit reporter attaches itsfail
handler first which serializes the error to a string for the later-generated XML beforeaddFullErrorIfMeaningful
is ever called to modifyerror.stack
.I fixed this by adding the
fail
handler before calling the JUnit constructor:junitWithFullErrors.js
: