Emit values even if they're 0
Closed this issue · 5 comments
Jameskmonger commented
I think we should emit fail
, todo
and skip
on complete
all the time, even if they're falsy.
That way it's easier to consume the event because you don't need to check for undefined when consuming it. It also makes the object schema a bit more consistent.
What do you guys think? @isaacs @sindresorhus @ljharb
isaacs commented
Seems reasonable to me. I think the only reason they're emitted is to reduce noise when they're output in yaml by harnesses. But that'd usually only happen on failure, so it's fine.
Jameskmonger commented
Great @isaacs
Would be a lot easier if I could do this:
parser.on("complete", results => {
let totals = {
pass: results.pass,
fail: results.fail,
skip: results.skip + results.todo
};
});
Rather than:
parser.on("complete", results => {
let totals = {
pass: results.pass,
fail: results.fail || 0,
skip: (results.skip || 0) + (results.todo || 0)
};
});
isaacs commented
Agreed! Patch welcome. Should be pretty straightforward.
Jameskmonger commented
Jameskmonger commented