Skip to content

Commit

Permalink
alter test to run well on jasmine too
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Feb 21, 2023
1 parent d4b5e47 commit 22df9f7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 34 deletions.
63 changes: 30 additions & 33 deletions e2e/__tests__/__snapshots__/failures.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -493,39 +493,36 @@ exports[`works with error with cause 1`] = `
`;
exports[`works with error with cause thrown outside tests 1`] = `
"FAIL __tests__/errorWithCauseInDescribe.test.js
● Test suite failed to run
error during f
10 |
11 | function buildErrorWithCause(message: string, opts: {cause: unknown}): Error {
> 12 | const error = new Error(message, opts);
| ^
13 | if (opts.cause !== error.cause) {
14 | // Error with cause not supported in legacy versions of node, we just polyfill it
15 | Object.assign(error, opts);
at buildErrorWithCause (__tests__/errorWithCauseInDescribe.test.js:12:17)
at buildErrorWithCause (__tests__/errorWithCauseInDescribe.test.js:27:11)
at f (__tests__/errorWithCauseInDescribe.test.js:32:3)
at Object.describe (__tests__/errorWithCauseInDescribe.test.js:31:1)
Cause:
error during g
19 |
20 | function g() {
> 21 | throw new Error('error during g');
| ^
22 | }
23 | function f() {
24 | try {
at g (__tests__/errorWithCauseInDescribe.test.js:21:9)
at g (__tests__/errorWithCauseInDescribe.test.js:25:5)
at f (__tests__/errorWithCauseInDescribe.test.js:32:3)
at Object.describe (__tests__/errorWithCauseInDescribe.test.js:31:1)"
"error during f
10 |
11 | function buildErrorWithCause(message: string, opts: {cause: unknown}): Error {
> 12 | const error = new Error(message, opts);
| ^
13 | if (opts.cause !== error.cause) {
14 | // Error with cause not supported in legacy versions of node, we just polyfill it
15 | Object.assign(error, opts);
at buildErrorWithCause (__tests__/errorWithCauseInDescribe.test.js:12:17)
at buildErrorWithCause (__tests__/errorWithCauseInDescribe.test.js:27:11)
at f (__tests__/errorWithCauseInDescribe.test.js:32:3)
at Object.describe (__tests__/errorWithCauseInDescribe.test.js:31:1)
Cause:
error during g
19 |
20 | function g() {
> 21 | throw new Error('error during g');
| ^
22 | }
23 | function f() {
24 | try {
at g (__tests__/errorWithCauseInDescribe.test.js:21:9)
at g (__tests__/errorWithCauseInDescribe.test.js:25:5)
at f (__tests__/errorWithCauseInDescribe.test.js:32:3)
at Object.describe (__tests__/errorWithCauseInDescribe.test.js:31:1)"
`;
exports[`works with node assert 1`] = `
Expand Down
11 changes: 10 additions & 1 deletion e2e/__tests__/failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,17 @@ test('works with error with cause', () => {
test('works with error with cause thrown outside tests', () => {
const {stderr} = runJest(dir, ['errorWithCauseInDescribe.test.js']);
const summary = normalizeDots(cleanStderr(stderr));
const sanitizedSummary = summary
.replace(/ Suite\.f /g, ' f ') // added by jasmine runner
.split('\n')
.map(line => line.trim()) // jasmine runner does not come with the same indentation
.join('\n');

expect(summary).toMatchSnapshot();
expect(
// jasmine runner differ from circus one in this case, we just start
// the comparison when the stack starts to be reported
sanitizedSummary.substring(sanitizedSummary.indexOf('error during f')),
).toMatchSnapshot();
});

test('errors after test has completed', () => {
Expand Down

0 comments on commit 22df9f7

Please sign in to comment.