Skip to content

Commit

Permalink
Improve snapshot error messages (#83785) (#83806)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dgieselaar and kibanamachine authored Nov 24, 2020
1 parent c642a15 commit 5beb243
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -228,7 +227,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(
Expand All @@ -240,5 +241,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());
}
}

0 comments on commit 5beb243

Please sign in to comment.