Skip to content

Commit

Permalink
Use wrap in e2e test for custom matcher stack trace
Browse files Browse the repository at this point in the history
Uses the new wrap utility in e2e snapshot for custom
matcher stack traces.
  • Loading branch information
Don Schrimsher committed Jan 22, 2019
1 parent 3018bc8 commit 023f108
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 32 deletions.
36 changes: 7 additions & 29 deletions e2e/__tests__/__snapshots__/customMatcherStackTrace.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`custom async matchers 1`] = `
Object {
"rest": "FAIL __tests__/async.test.js
FAIL __tests__/asynchronous.test.js
✕ showing the stack trace for an async matcher
● showing the stack trace for an async matcher
Expand All @@ -17,35 +16,16 @@ Object {
6 |
7 | async function toThrowCustomAsyncMatcherError() {
at Object.toThrowCustomAsyncMatcherError (__tests__/async.test.js:4:22)
",
"summary": "Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites matching /async.test.js/i.
",
}
at Object.toThrowCustomAsyncMatcherError (__tests__/asynchronous.test.js:4:22)
`;
exports[`works with custom matchers 1`] = `
"FAIL __tests__/async.test.js
showing the stack trace for an async matcher
We expect the stack trace and code fence for this matcher to be shown in the console.
2 |
3 | test('showing the stack trace for an async matcher', async () => {
> 4 | await expect(true).toThrowCustomAsyncMatcherError();
| ^
5 | });
6 |
7 | async function toThrowCustomAsyncMatcherError() {
at Object.toThrowCustomAsyncMatcherError (__tests__/async.test.js:4:22)
FAIL __tests__/sync.test.js
Custom matcher
passes
fails
preserves error stack
Custom matcherpreserves error stack
qux
Expand All @@ -64,6 +44,4 @@ FAIL __tests__/sync.test.js
at foo (__tests__/sync.test.js:52:7)
at Object.callback (__tests__/sync.test.js:11:18)
at Object.toCustomMatch (__tests__/sync.test.js:53:8)
"
`;
8 changes: 5 additions & 3 deletions e2e/__tests__/customMatcherStackTrace.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ test('works with custom matchers', () => {
});

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

const result = extractSummary(stderr);
const {rest} = extractSummary(stderr);

expect(result).toMatchSnapshot();
expect(wrap(rest)).toMatchSnapshot();
});

0 comments on commit 023f108

Please sign in to comment.