mocha
mocha copied to clipboard
Custom reporter and event handling
I'm writing my own reporter and on failure taking a screenshot and saving to disc. But it seems that the event onEnd doesn't wait for my event onFailure to finish.
The process ends after on end and my screenshots is never saved to disc. Tried to push my promises in onFailure to an array and in onEnd use Promise.settle but that doesn't work.
Is there any way of running onEnd first after all other events has finished?
+1 I have a similar problem where I am trying to get a reporter to post the results to testrail, but mocha will not wait for callbacks or promises and just kills the reporter when the tests end.
@jaydlawrence Nice to know there are peeps out there looking to do testrail mocha integration.
Did you guys have any luck with this ?
It does not, I believe it is related to Process event exit. I was able to successfully fork and do some additional work.
I know Runner#run
will invoke end game processing. But the reporter's onEnd
handler should have been registered to run prior to the runner's handler.
After your reporter registers your end
handler, where does it show up positionally?
runner.listeners('end').forEach(function(func) {
console.log(func.toString());
});
It can be forced to the front using this method instead of Emitter#on
runner.prependListener('end', onReporterEnd);
@axelssonHakan, @jaydlawrence, @carsonreinke: Do any of you have code that demonstrates the problem for testing?
Hello there, does any of participants have update in this issue? I'm currently trying to write custom reporter to azure devops for Cypress and facing same issue (async HTTP request call at the end of run isn't proceeded).
This open question has existed for quite a while without a concrete answer. Per #5027 we've moved question-asking to Discord. If you're reading this and interested, please:
- Search other issues for what you're trying to do
- Ask there or StackOverflow
Cheers!