From 023f108c65eba1960c4c9f4048de44df1bb11cfb Mon Sep 17 00:00:00 2001 From: Don Schrimsher Date: Mon, 21 Jan 2019 20:02:29 -0500 Subject: [PATCH] Use wrap in e2e test for custom matcher stack trace Uses the new wrap utility in e2e snapshot for custom matcher stack traces. --- .../customMatcherStackTrace.test.js.snap | 36 ++++--------------- e2e/__tests__/customMatcherStackTrace.test.js | 8 +++-- .../{async.test.js => asynchronous.test.js} | 0 3 files changed, 12 insertions(+), 32 deletions(-) rename e2e/custom-matcher-stack-trace/__tests__/{async.test.js => asynchronous.test.js} (100%) diff --git a/e2e/__tests__/__snapshots__/customMatcherStackTrace.test.js.snap b/e2e/__tests__/__snapshots__/customMatcherStackTrace.test.js.snap index 4a6b5758e60d..587b29269dee 100644 --- a/e2e/__tests__/__snapshots__/customMatcherStackTrace.test.js.snap +++ b/e2e/__tests__/__snapshots__/customMatcherStackTrace.test.js.snap @@ -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 @@ -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: <> -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 matcher › preserves error stack qux @@ -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) - -" `; diff --git a/e2e/__tests__/customMatcherStackTrace.test.js b/e2e/__tests__/customMatcherStackTrace.test.js index a4a8971d72b4..be338b2b7ee7 100644 --- a/e2e/__tests__/customMatcherStackTrace.test.js +++ b/e2e/__tests__/customMatcherStackTrace.test.js @@ -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(); }); diff --git a/e2e/custom-matcher-stack-trace/__tests__/async.test.js b/e2e/custom-matcher-stack-trace/__tests__/asynchronous.test.js similarity index 100% rename from e2e/custom-matcher-stack-trace/__tests__/async.test.js rename to e2e/custom-matcher-stack-trace/__tests__/asynchronous.test.js