Skip to content

Commit

Permalink
jest-circus: remove switch with single case (#9166)
Browse files Browse the repository at this point in the history
  • Loading branch information
Connormiha authored and jeysal committed Nov 11, 2019
1 parent 2cde649 commit 6f42949
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions packages/jest-circus/src/formatNodeAssertErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,30 @@ const humanReadableOperators: Record<string, string> = {
};

const formatNodeAssertErrors = (event: Circus.Event, state: Circus.State) => {
switch (event.name) {
case 'test_done': {
event.test.errors = event.test.errors.map((errors: Circus.TestError) => {
let error;
if (Array.isArray(errors)) {
const [originalError, asyncError] = errors;

if (originalError == null) {
error = asyncError;
} else if (!originalError.stack) {
error = asyncError;

error.message = originalError.message
? originalError.message
: `thrown: ${prettyFormat(originalError, {maxDepth: 3})}`;
} else {
error = originalError;
}
if (event.name === 'test_done') {
event.test.errors = event.test.errors.map((errors: Circus.TestError) => {
let error;
if (Array.isArray(errors)) {
const [originalError, asyncError] = errors;

if (originalError == null) {
error = asyncError;
} else if (!originalError.stack) {
error = asyncError;

error.message = originalError.message
? originalError.message
: `thrown: ${prettyFormat(originalError, {maxDepth: 3})}`;
} else {
error = errors;
error = originalError;
}
return isAssertionError(error)
? {message: assertionErrorMessage(error, {expand: state.expand})}
: errors;
});
}
} else {
error = errors;
}
return isAssertionError(error)
? {message: assertionErrorMessage(error, {expand: state.expand})}
: errors;
});
}
};

Expand Down

0 comments on commit 6f42949

Please sign in to comment.