Skip to content

Commit 023f108

Browse files
author
Don Schrimsher
committed
Use wrap in e2e test for custom matcher stack trace
Uses the new wrap utility in e2e snapshot for custom matcher stack traces.
1 parent 3018bc8 commit 023f108

3 files changed

Lines changed: 12 additions & 32 deletions

File tree

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`custom async matchers 1`] = `
4-
Object {
5-
"rest": "FAIL __tests__/async.test.js
4+
FAIL __tests__/asynchronous.test.js
65
✕ showing the stack trace for an async matcher
76
87
● showing the stack trace for an async matcher
@@ -17,35 +16,16 @@ Object {
1716
6 |
1817
7 | async function toThrowCustomAsyncMatcherError() {
1918
20-
at Object.toThrowCustomAsyncMatcherError (__tests__/async.test.js:4:22)
21-
22-
",
23-
"summary": "Test Suites: 1 failed, 1 total
24-
Tests: 1 failed, 1 total
25-
Snapshots: 0 total
26-
Time: <<REPLACED>>
27-
Ran all test suites matching /async.test.js/i.
28-
",
29-
}
19+
at Object.toThrowCustomAsyncMatcherError (__tests__/asynchronous.test.js:4:22)
3020
`;
3121
3222
exports[`works with custom matchers 1`] = `
33-
"FAIL __tests__/async.test.js
34-
showing the stack trace for an async matcher
35-
36-
We expect the stack trace and code fence for this matcher to be shown in the console.
37-
38-
2 |
39-
3 | test('showing the stack trace for an async matcher', async () => {
40-
> 4 | await expect(true).toThrowCustomAsyncMatcherError();
41-
| ^
42-
5 | });
43-
6 |
44-
7 | async function toThrowCustomAsyncMatcherError() {
45-
46-
at Object.toThrowCustomAsyncMatcherError (__tests__/async.test.js:4:22)
47-
4823
FAIL __tests__/sync.test.js
24+
Custom matcher
25+
passes
26+
fails
27+
preserves error stack
28+
4929
Custom matcherpreserves error stack
5030
5131
qux
@@ -64,6 +44,4 @@ FAIL __tests__/sync.test.js
6444
at foo (__tests__/sync.test.js:52:7)
6545
at Object.callback (__tests__/sync.test.js:11:18)
6646
at Object.toCustomMatch (__tests__/sync.test.js:53:8)
67-
68-
"
6947
`;

e2e/__tests__/customMatcherStackTrace.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ test('works with custom matchers', () => {
2525
});
2626

2727
test('custom async matchers', () => {
28-
const {stderr} = runJest('custom-matcher-stack-trace', ['async.test.js']);
28+
const {stderr} = runJest('custom-matcher-stack-trace', [
29+
'asynchronous.test.js',
30+
]);
2931

30-
const result = extractSummary(stderr);
32+
const {rest} = extractSummary(stderr);
3133

32-
expect(result).toMatchSnapshot();
34+
expect(wrap(rest)).toMatchSnapshot();
3335
});

e2e/custom-matcher-stack-trace/__tests__/async.test.js renamed to e2e/custom-matcher-stack-trace/__tests__/asynchronous.test.js

File renamed without changes.

0 commit comments

Comments
 (0)