Skip to content

Commit

Permalink
fix and improve
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Oct 11, 2022
1 parent a39810a commit 31d795c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/jest-circus/src/index.ts
Expand Up @@ -186,9 +186,9 @@ const test: Global.It = (() => {
) => void,
timeout?: number,
failing?: boolean,
error?: Error,
asyncError?: Error,
) => {
const asyncError = error || new ErrorWithStack(undefined, testFn);
asyncError = asyncError || new ErrorWithStack(undefined, testFn);

try {
testName = convertDescriptorToString(testName);
Expand Down
1 change: 1 addition & 0 deletions packages/jest-console/src/BufferedConsole.ts
Expand Up @@ -79,6 +79,7 @@ export default class BufferedConsole extends Console {
if (!(error instanceof AssertionError)) {
throw error;
}
// https://github.com/facebook/jest/pull/13422#issuecomment-1273396392
this._log('assert', error.toString().replace(/:\n\n.*\n/gs, ''));
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/jest-console/src/CustomConsole.ts
Expand Up @@ -56,6 +56,7 @@ export default class CustomConsole extends Console {
if (!(error instanceof AssertionError)) {
throw error;
}
// https://github.com/facebook/jest/pull/13422#issuecomment-1273396392
this._logError('assert', error.toString().replace(/:\n\n.*\n/gs, ''));
}
}
Expand Down
11 changes: 8 additions & 3 deletions packages/jest-each/src/bind.ts
Expand Up @@ -66,9 +66,14 @@ export default function bind<EachCallback extends Global.TestCallback>(
),
);
} catch (e: any) {
const err = new Error(e.message);
err.stack = error.stack?.replace(/^Error: /s, e.message);
err.name = '';
let err = new Error(e.message);

// CIRCUS
if (typeof 'it' === 'function') {
err.stack = error.stack?.replace(/^Error: /s, e.message);
} else {
err.stack = error.stack;
}

return cb(title, () => {
throw err;
Expand Down

0 comments on commit 31d795c

Please sign in to comment.