From 0b90cb5004b82afc1df93c4677b2b054f55cbb9e Mon Sep 17 00:00:00 2001 From: Jason Cheatham Date: Mon, 12 Sep 2016 10:16:00 -0400 Subject: [PATCH] Understand new filterErrorStack config option When this option is true, error stack lines relating to 'internal/process' and 'node_modules' modules will be filtered out. In the future, this option may also allow a regex, similar to excludeInstrumentation. --- lib/util.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/util.js b/lib/util.js index 1508e9176..512cc85ef 100644 --- a/lib/util.js +++ b/lib/util.js @@ -4,6 +4,7 @@ define([ 'dojo/lang', 'dojo/Promise', './EnvironmentType', + '../main', 'diff', 'dojo/has!host-node?dojo/node!glob', 'dojo/has!host-node?dojo/node!path', @@ -16,6 +17,7 @@ define([ lang, Promise, EnvironmentType, + intern, diffUtil, glob, pathUtil, @@ -466,7 +468,7 @@ define([ /** * Parse a stack trace, apply any source mappings, and normalize its format. */ - function normalizeStackTrace(stack) { + function normalizeStackTrace(stack, filterStack) { var lines = stack.replace(/\s+$/, '').split('\n'); var firstLine = ''; @@ -482,6 +484,16 @@ define([ } stack = /^\s*at /.test(lines[0]) ? processChromeTrace(lines) : processSafariTrace(lines); + + if (filterStack) { + stack = stack.filter(function (line) { + return !( + /internal\/process\//.test(line) || + /node_modules\//.test(line) + ); + }); + } + return '\n' + firstLine + stack.join('\n'); } @@ -633,7 +645,8 @@ define([ stack = stack.slice(String(error.message).length); } - stack = normalizeStackTrace(stack); + var filterStack = intern && intern.config && intern.config.filterErrorStack; + stack = normalizeStackTrace(stack, filterStack); } if (error.showDiff && typeof error.actual === 'object' && typeof error.expected === 'object') {