-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Bug: Tap reporter doesn't adhere to spec #2410
Comments
seems reasonable, thanks for reporting |
I am a bot that watches issues for inactivity. |
not stale |
I'm looking at bringing the TAP reporter up to v13 spec (see #3452) and trying to conceive a Good Solution for this issue. Currently this fixture 'use strict';
describe('Animals', function() {
it('should consume organic material', function(done) { done(); });
it('should breathe oxygen', function(done) { done(); });
it('should be able to move', function(done) { done(); });
it('should reproduce sexually', function(done) { done(); });
it('should grow from a hollow sphere of cells', function(done) { done(); });
describe('Vertebrates', function() {
describe('Mammals', function() {
it('should give birth to live young', function(done) { done(); });
describe('Blue Whale', function() {
it('should be the largest of all mammals', function(done) { done(); });
it('should have a body in some shade of blue', function(done) { done(); });
});
});
describe('Birds', function() {
it('should have feathers', function(done) { done(); });
it('should lay hard-shelled eggs', function(done) { done(); });
});
});
describe('Tardigrades', function() {
it('should answer to "water bear"', function(done) { done(); });
it('should be able to survive global mass extinction events', function(done) { done(); });
});
}); results in the following TAP report output
which piped into the latest version of
while the same fixture using the spec reporter directly has a nice hierarchy
Possible solutionsSo this is where we are. Now a first approach would be to output describes as
I kind of like it over the original flat output, but the trimming of prefixed whitespace is a bit sad (limitation in tap-spec I guess?). But hey, if we insert a prefix in the comment it won't trim following whitespace:
Cool… but the actual results will never be paddded, and now In the end it feels like we're trying to work around limitations in tap-spec, and the TAP specification v13 has no concept of suites and subtests as far a I can tell. Honestly, it would be more reasonable in my opinion to make a TAP consumer (an alternative to Any thoughts? |
Looking at the spec I think the best solution is saving "depth" or "parent" in the YAML block segment following the test. I've only seen it used in the spec and in implementations for extra information regarding failed tests (message, source line, stack) but the spec allows it after any test line. But that requires TAP consumers to implement support for it, but I mean it wouldn't be that crazy. For reference I recreated the fixture in tape, which does have the concept of subtests, but the report is flattened… var test = require('tape');
test('Animals', function(a) {
a.pass('should consume organic material');
a.pass('should breathe oxygen');
a.pass('should be able to move');
a.pass('should reproduce sexually');
a.pass('should grow from a hollow sphere of cells');
a.test('Vertebrates', function(b) {
b.test('Mammals', function(c) {
c.pass('should give birth to live young');
c.test('Blue Whale', function(d) {
d.pass('should be the largest of all mammals');
d.pass('should have a body in some shade of blue');
d.end();
});
c.end();
});
b.test('Birds', function(e) {
e.pass('should have feathers');
e.pass('should lay hard-shelled eggs');
e.end();
});
});
a.test('Tardigrades', function(f) {
f.pass('should answer to "water bear"');
f.pass('should be able to survive global mass extinction events');
f.end();
});
a.end();
});
node-tap has the concept of subtests, but I'm not sure what's going on here. This isn't spec compliant if I'm not mistaken: https://www.node-tap.org/subtests/ 🦊 |
It currently generates output like this:
for
It just flattens out
describe
s and prepends them the to test name.This makes the
tap-spec
reporter unable to recognize test-cases.I think a viable alternative would be to print diagnostic messages for describe blocks.
prints
Nested describes should be concatened though I suppose.
The text was updated successfully, but these errors were encountered: