Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update @babel/* deps #13422

Merged
merged 16 commits into from
Oct 11, 2022
24 changes: 12 additions & 12 deletions e2e/__tests__/__snapshots__/each.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ exports[`shows error message when not enough arguments are supplied to tests 1`]

Missing 1 argument

6 | */
7 |
> 8 | it.each\`
| ^
9 | left | right
10 | \${true} | \${true}
11 | \${true}
> 12 | \`(
| ^
13 | 'throws exception when one argument too few are supplied $left == $right',
14 | ({left, right}) => {
15 | expect(left).toBe(right);

at Object.<anonymous> (__tests__/eachException.test.js:12:2)
at Object.<anonymous> (__tests__/eachException.test.js:8:9)

● throws exception when not enough arguments are supplied $left == $right

Expand All @@ -83,15 +83,15 @@ exports[`shows error message when not enough arguments are supplied to tests 1`]

Missing 2 arguments

17 | );
18 |
> 19 | it.each\`
| ^
20 | left | right | up | down
21 | \${true} | \${true}
> 22 | \`(
| ^
23 | 'throws exception when not enough arguments are supplied $left == $right',
24 | ({left, right}) => {
25 | expect(left).toBe(right);
22 | \`(

at Object.<anonymous> (__tests__/eachException.test.js:22:2)"
at Object.<anonymous> (__tests__/eachException.test.js:19:9)"
`;

exports[`shows only the tests with .only as being ran 1`] = `
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-console/src/BufferedConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class BufferedConsole extends Console {
if (!(error instanceof AssertionError)) {
throw error;
}
this._log('assert', error.toString());
this._log('assert', error.toString().replace(/:\n\n.*\n/gs, ''));
SimenB marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-console/src/CustomConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class CustomConsole extends Console {
if (!(error instanceof AssertionError)) {
throw error;
}
this._logError('assert', error.toString());
this._logError('assert', error.toString().replace(/:\n\n.*\n/gs, ''));
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/jest-console/src/__tests__/bufferedConsole.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ describe('CustomConsole', () => {
_console.assert(false);

expect(stdout()).toMatch('AssertionError');
expect(stdout()).toMatch('false == true');
expect(stdout()).toMatch(
/false == true|The expression evaluated to a falsy value/,
SimenB marked this conversation as resolved.
Show resolved Hide resolved
);
});

test('log the assertion error when the assertion is falsy with another message argument', () => {
Expand Down
17 changes: 12 additions & 5 deletions packages/jest-each/src/bind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ export default function bind<EachCallback extends Global.TestCallback>(
cb: GlobalCallback,
supportsDone = true,
) {
return (
const bindWrap = (
table: Global.EachTable,
...taggedTemplateData: Global.TemplateData
) =>
function eachBind(
) => {
const error = new ErrorWithStack('', bindWrap);
Copy link
Member

@SimenB SimenB Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! I actually opened this PR now to start working on this 😀 wonderful timing


return function eachBind(
title: Global.BlockNameLike,
test: Global.EachTestFn<EachCallback>,
timeout?: number,
Expand All @@ -55,12 +57,17 @@ export default function bind<EachCallback extends Global.TestCallback>(
),
);
} catch (e: any) {
const error = new ErrorWithStack(e.message, eachBind);
const err = new Error(e.message);
err.stack = error.stack?.replace(/^Error: /s, e.message);
err.name = e.name;

return cb(title, () => {
throw error;
throw err;
});
}
};
};
return bindWrap;
}

const isArrayTable = (data: Global.TemplateData) => data.length === 0;
Expand Down