Skip to content

Commit

Permalink
full stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 28, 2019
1 parent d340bc6 commit 0769ee9
Showing 1 changed file with 2 additions and 63 deletions.
65 changes: 2 additions & 63 deletions packages/jest-message-util/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ const stackUtils = new StackUtils({
cwd: 'something which does not exist',
});

let nodeInternals: RegExp[] = [];

try {
nodeInternals = StackUtils.nodeInternals();
} catch (e) {
// `StackUtils.nodeInternals()` fails in browsers. We don't need to remove
// node internals in the browser though, so no issue.
}

export type StackTraceConfig = Pick<
Config.ProjectConfig,
'rootDir' | 'testMatch'
Expand All @@ -48,12 +39,6 @@ const PATH_NODE_MODULES = `${path.sep}node_modules${path.sep}`;
const PATH_JEST_PACKAGES = `${path.sep}jest${path.sep}packages${path.sep}`;

// filter for noisy stack trace lines
const JASMINE_IGNORE = /^\s+at(?:(?:.jasmine\-)|\s+jasmine\.buildExpectationResult)/;
const JEST_INTERNALS_IGNORE = /^\s+at.*?jest(-.*?)?(\/|\\)(build|node_modules|packages)(\/|\\)/;
const ANONYMOUS_FN_IGNORE = /^\s+at <anonymous>.*$/;
const ANONYMOUS_PROMISE_IGNORE = /^\s+at (new )?Promise \(<anonymous>\).*$/;
const ANONYMOUS_GENERATOR_IGNORE = /^\s+at Generator.next \(<anonymous>\).*$/;
const NATIVE_NEXT_IGNORE = /^\s+at next \(native\).*$/;
const TITLE_INDENT = ' ';
const MESSAGE_INDENT = ' ';
const STACK_INDENT = ' ';
Expand Down Expand Up @@ -152,54 +137,8 @@ export const formatExecError = (

const removeInternalStackEntries = (
lines: string[],
options: StackTraceOptions,
): string[] => {
let pathCounter = 0;

return lines.filter(line => {
if (ANONYMOUS_FN_IGNORE.test(line)) {
return false;
}

if (ANONYMOUS_PROMISE_IGNORE.test(line)) {
return false;
}

if (ANONYMOUS_GENERATOR_IGNORE.test(line)) {
return false;
}

if (NATIVE_NEXT_IGNORE.test(line)) {
return false;
}

if (nodeInternals.some(internal => internal.test(line))) {
return false;
}

if (!STACK_PATH_REGEXP.test(line)) {
return true;
}

if (JASMINE_IGNORE.test(line)) {
return false;
}

if (++pathCounter === 1) {
return true; // always keep the first line even if it's from Jest
}

if (options.noStackTrace) {
return false;
}

if (JEST_INTERNALS_IGNORE.test(line)) {
return false;
}

return true;
});
};
_options: StackTraceOptions,
): string[] => lines;

const formatPaths = (
config: StackTraceConfig,
Expand Down

0 comments on commit 0769ee9

Please sign in to comment.