Skip to content

Commit

Permalink
Understand new filterErrorStack config option
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jason0x43 committed Sep 23, 2016
1 parent 64e47e7 commit 0b90cb5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/util.js
Expand Up @@ -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',
Expand All @@ -16,6 +17,7 @@ define([
lang,
Promise,
EnvironmentType,
intern,
diffUtil,
glob,
pathUtil,
Expand Down Expand Up @@ -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 = '';

Expand All @@ -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');
}

Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit 0b90cb5

Please sign in to comment.