[Pkg-javascript-commits] [node-tap-mocha-reporter] 87/137: Make the markdown outputter work
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Sep 7 09:49:29 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-tap-mocha-reporter.
commit 55a34c3eb35a22ee32d448c2ab1362bacc67ba6f
Author: isaacs <i at izs.me>
Date: Sun Jan 31 13:31:33 2016 -0800
Make the markdown outputter work
fixes tapjs/node-tap#224
---
lib/reporters/markdown.js | 48 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 37 insertions(+), 11 deletions(-)
diff --git a/lib/reporters/markdown.js b/lib/reporters/markdown.js
index e14174c..ea616b9 100644
--- a/lib/reporters/markdown.js
+++ b/lib/reporters/markdown.js
@@ -33,7 +33,7 @@ function Markdown(runner) {
, buf = '';
function title(str) {
- return Array(level).join('#') + ' ' + str;
+ return Array(level + 1).join('#') + ' ' + str;
}
function indent() {
@@ -66,14 +66,22 @@ function Markdown(runner) {
return buf;
}
- function generateTOC(suite) {
+ function generateTOC() {
+ return suites.map(generateTOC_).join('')
+ }
+
+ function generateTOC_(suite) {
var obj = mapTOC(suite, {});
return stringifyTOC(obj, 0);
}
- generateTOC(runner.suite);
-
+ var suites = []
+ var currentSuite = null
runner.on('suite', function(suite){
+ currentSuite = suite
+ if (suite.root) {
+ suites.push(suite)
+ }
++level;
var slug = utils.slug(suite.fullTitle());
buf += '<a name="' + slug + '"></a>' + '\n';
@@ -81,20 +89,38 @@ function Markdown(runner) {
});
runner.on('suite end', function(suite){
+ if (suite.ok) {
+ buf += '\nok - ' + suite.title + '\n'
+ } else {
+ buf += '\nnot ok - ' + suite.title + '\n'
+ }
--level;
});
- runner.on('pass', function(test){
- var code = utils.clean(test.fn.toString());
- buf += test.title + '.\n';
- buf += '\n```js\n';
- buf += code + '\n';
- buf += '```\n\n';
+ runner.on('test', function(test){
+ if (!test.ok || test.pending) {
+ var code = utils.clean(test.fn.toString());
+ buf += test.title + '.\n';
+ if (code) {
+ buf += '\n```js\n';
+ buf += code + '\n';
+ buf += '```\n';
+ }
+ var stack = test.err && test.err.stack
+ if (!stack) {
+ stack = test.result && test.result.diag && test.result.diag.stack
+ }
+ if (stack) {
+ buf += '\n```\n' + stack + '\n```\n';
+ }
+ buf += '\n\n';
+ }
});
runner.on('end', function(){
process.stdout.write('# TOC\n');
- process.stdout.write(generateTOC(runner.suite));
+ process.stdout.write(generateTOC());
+ process.stdout.write('\n\n');
process.stdout.write(buf);
});
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-tap-mocha-reporter.git
More information about the Pkg-javascript-commits
mailing list