Skip to content

Commit

Permalink
Merge pull request #2068 from danielstjules/dstjules/test-body
Browse files Browse the repository at this point in the history
Fix 2067: HTML/DOC reporter regression with async failures
  • Loading branch information
boneskull committed Jan 26, 2016
2 parents a25ac95 + d59cc6c commit f00c197
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/reporters/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ function Doc(runner) {

runner.on('pass', function(test) {
console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title));
var code = utils.escape(utils.clean(test.fn.toString()));
var code = utils.escape(utils.clean(test.body));
console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
});

runner.on('fail', function(test, err) {
console.log('%s <dt class="error">%s</dt>', indent(), utils.escape(test.title));
var code = utils.escape(utils.clean(test.fn.toString()));
var code = utils.escape(utils.clean(test.fn.body));
console.log('%s <dd class="error"><pre><code>%s</code></pre></dd>', indent(), code);
console.log('%s <dd class="error">%s</dd>', indent(), utils.escape(err));
});
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function HTML(runner) {
pre.style.display = pre.style.display === 'none' ? 'block' : 'none';
});

var pre = fragment('<pre><code>%e</code></pre>', utils.clean(test.fn.toString()));
var pre = fragment('<pre><code>%e</code></pre>', utils.clean(test.body));
el.appendChild(pre);
pre.style.display = 'none';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function Markdown(runner) {
});

runner.on('pass', function(test) {
var code = utils.clean(test.fn.toString());
var code = utils.clean(test.body);
buf += test.title + '.\n';
buf += '\n```js\n';
buf += code + '\n';
Expand Down
1 change: 1 addition & 0 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function Test(title, fn) {
Runnable.call(this, title, fn);
this.pending = !fn;
this.type = 'test';
this.body = (fn || '').toString();
}

/**
Expand Down

0 comments on commit f00c197

Please sign in to comment.