commit ffff044ce6c4dfd2bfa127965c956ba7aba949b7 parent dbf47a3e1e6896a5a7729b2f48c0d94534562141 Author: Dan Stillman <dstillman@zotero.org> Date: Tue, 2 Jun 2015 16:31:33 -0400 Add stack traces to Chai assertion failures Diffstat:
| M | test/content/runtests.js | | | 15 | +++++++++++++++ |
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/test/content/runtests.js b/test/content/runtests.js @@ -117,6 +117,21 @@ function Reporter(runner) { }); runner.on('fail', function(test, err){ + // Strip Chai lines from stack trace + err.stack = err.stack.replace(/.+zotero-unit\/chai.+\n/g, ""); + // Strip "From previous event:" block if it's all internals + var re = /\s*From previous event:(.|\n)+/; + var matches = re.exec(err.stack); + if (matches) { + err.stack = err.stack.substr(0, matches.index); + var previous = matches[0].split(/\n/) + .filter(line => line.indexOf('zotero-unit/') == -1).join('\n'); + if (previous.trim() != "From previous event:") { + err.stack += previous; + } + } + err.stack += "\n"; + failed++; dump("\r" + indent() // Dark red X for errors