Skip to content
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

Updating TAP reporter to specification version 13 #163

Merged
merged 2 commits into from Aug 20, 2014
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -17,9 +17,21 @@ exports = module.exports = internals.Reporter = function (options) {
this.counter = 0;
};

internals.Reporter.prototype.insertYAMLBlock = function(test) {

this.report(' ---\n');
this.report(' duration_ms: ' + test.duration + '\n');
if (test.err && test.err.stack) {
this.report(' stack: |-\n');
this.report(' ' + test.err.stack.replace(/(\n|\r\n)/gm, '\n ') + '\n');
}
this.report(' ...\n');
};


internals.Reporter.prototype.start = function (notebook) {

this.report('TAP version 13\n');
this.report('1..' + notebook.count + '\n');
};

@@ -32,21 +44,20 @@ internals.Reporter.prototype.test = function (test) {
if (test.err) {
++this.failures;
this.report('not ok ' + id + ' ' + title + '\n');
if (test.err.stack) {
this.report(test.err.stack.replace(/^/gm, ' ') + '\n');
}
this.insertYAMLBlock(test);
}
else if (test.skipped) {
++this.skipped;
this.report('ok ' + id + ' SKIP ' + title + '\n');
this.report('ok ' + id + ' # SKIP ' + title + '\n');
}
else if (test.todo) {
++this.todo;
this.report('ok ' + id + ' TODO ' + title + '\n');
this.report('ok ' + id + ' # TODO ' + title + '\n');
}
else {
++this.passes;
this.report('ok ' + id + ' ' + title + '\n');
this.insertYAMLBlock(test);
}
};

@@ -58,5 +69,4 @@ internals.Reporter.prototype.end = function (notebook) {
this.report('# fail ' + this.failures + '\n');
this.report('# skipped ' + this.skipped + '\n');
this.report('# todo ' + this.todo + '\n');
};

};

This comment has been minimized.

Copy link
@geek

geek Aug 19, 2014

Member

missing newline

@@ -746,8 +746,8 @@ describe('Reporter', function () {

expect(err).to.not.exist;
expect(code).to.equal(1);
var result = output.replace(/ .*\n/g, '<trace>');
expect(result).to.equal('1..5\nok 1 (1) test works\nok 2 SKIP (2) test skip\nok 3 TODO (3) test todo\nnot ok 4 (4) test fails\n<trace><trace><trace><trace><trace><trace>not ok 5 (5) test fails with non-error\n# tests 4\n# pass 1\n# fail 2\n# skipped 1\n# todo 1\n');
var result = output.replace(/ .*\n/g, ' <trace>\n').replace(/ duration_ms: .*\n/g, " duration_ms: 123\n");
expect(result).to.equal('TAP version 13\n1..5\nok 1 (1) test works\n ---\n duration_ms: 123\n ...\nok 2 # SKIP (2) test skip\nok 3 # TODO (3) test todo\nnot ok 4 (4) test fails\n ---\n duration_ms: 123\n stack: |-\n AssertionError: expected true to equal false\n <trace>\n <trace>\n <trace>\n <trace>\n <trace>\n ...\nnot ok 5 (5) test fails with non-error\n ---\n duration_ms: 123\n ...\n# tests 4\n# pass 1\n# fail 2\n# skipped 1\n# todo 1\n');
done();
});
});
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.