tap-mocha-reporter
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -36,3 +36,3 @@ /** | ||
function title(str) { | ||
return Array(level).join('#') + ' ' + str; | ||
return Array(level + 1).join('#') + ' ' + str; | ||
} | ||
@@ -70,3 +70,7 @@ | ||
function generateTOC(suite) { | ||
function generateTOC() { | ||
return suites.map(generateTOC_).join('') | ||
} | ||
function generateTOC_(suite) { | ||
var obj = mapTOC(suite, {}); | ||
@@ -76,5 +80,9 @@ 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; | ||
@@ -87,11 +95,28 @@ var slug = utils.slug(suite.fullTitle()); | ||
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'; | ||
} | ||
}); | ||
@@ -101,5 +126,6 @@ | ||
process.stdout.write('# TOC\n'); | ||
process.stdout.write(generateTOC(runner.suite)); | ||
process.stdout.write(generateTOC()); | ||
process.stdout.write('\n\n'); | ||
process.stdout.write(buf); | ||
}); | ||
} |
{ | ||
"name": "tap-mocha-reporter", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "Format a TAP stream using Mocha's set of reporters", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112083
47
3253
119114