Skip to content

Commit 7ce8052

Browse files
committed
Improve snapshot error messages
1 parent 3a8ea29 commit 7ce8052

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/kbn-test/src/functional_test_runner/lib/snapshots/decorate_snapshot_ui.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
addSerializer,
2525
} from 'jest-snapshot';
2626
import path from 'path';
27-
import expect from '@kbn/expect';
2827
import prettier from 'prettier';
2928
import babelTraverse from '@babel/traverse';
3029
import { flatten, once } from 'lodash';
@@ -227,7 +226,9 @@ function expectToMatchSnapshot(snapshotContext: SnapshotContext, received: any)
227226
const matcher = toMatchSnapshot.bind(snapshotContext as any);
228227
const result = matcher(received);
229228

230-
expect(result.pass).to.eql(true, result.message());
229+
if (!result.pass) {
230+
throw new Error(result.message());
231+
}
231232
}
232233

233234
function expectToMatchInlineSnapshot(
@@ -239,5 +240,7 @@ function expectToMatchInlineSnapshot(
239240

240241
const result = arguments.length === 2 ? matcher(received) : matcher(received, _actual);
241242

242-
expect(result.pass).to.eql(true, result.message());
243+
if (!result.pass) {
244+
throw new Error(result.message());
245+
}
243246
}

0 commit comments

Comments
 (0)