From 5d05eeaab98d3ac1bdf5600864a367608f2fc4c2 Mon Sep 17 00:00:00 2001 From: Dario Gieselaar Date: Thu, 19 Nov 2020 15:58:15 +0100 Subject: [PATCH] Improve snapshot error messages (#83785) --- .../lib/snapshots/decorate_snapshot_ui.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/kbn-test/src/functional_test_runner/lib/snapshots/decorate_snapshot_ui.ts b/packages/kbn-test/src/functional_test_runner/lib/snapshots/decorate_snapshot_ui.ts index 45550b55e73c7..6004c48521c6d 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/snapshots/decorate_snapshot_ui.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/snapshots/decorate_snapshot_ui.ts @@ -24,7 +24,6 @@ import { addSerializer, } from 'jest-snapshot'; import path from 'path'; -import expect from '@kbn/expect'; import prettier from 'prettier'; import babelTraverse from '@babel/traverse'; import { flatten, once } from 'lodash'; @@ -227,7 +226,9 @@ function expectToMatchSnapshot(snapshotContext: SnapshotContext, received: any) const matcher = toMatchSnapshot.bind(snapshotContext as any); const result = matcher(received); - expect(result.pass).to.eql(true, result.message()); + if (!result.pass) { + throw new Error(result.message()); + } } function expectToMatchInlineSnapshot( @@ -239,5 +240,7 @@ function expectToMatchInlineSnapshot( const result = arguments.length === 2 ? matcher(received) : matcher(received, _actual); - expect(result.pass).to.eql(true, result.message()); + if (!result.pass) { + throw new Error(result.message()); + } }