tapjs/tap-parser

Emit values even if they're 0

Closed this issue · 5 comments

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

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.

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)
    };
});

Agreed! Patch welcome. Should be pretty straightforward.

@isaacs this has been submitted for PR in #44

Closed by #44, thanks @isaacs