-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Expand file tree
/
Copy pathmatcher.test.js
More file actions
42 lines (35 loc) · 961 Bytes
/
matcher.test.js
File metadata and controls
42 lines (35 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
'use strict';
const {toMatchSnapshot} = require('../');
it(`matcher returns matcher name, expected and actual values`, () => {
const actual = 'a';
const expected = 'b';
const matcher = toMatchSnapshot.bind({
snapshotState: {match: (testName, received) => ({actual, expected})},
});
const matcherResult = matcher({a: 1});
expect(matcherResult).toEqual(
expect.objectContaining({
actual,
expected,
name: 'toMatchSnapshot',
}),
);
});
it(`throws the error stack when match throws an error`, () => {
const error = new Error();
const matcher = toMatchSnapshot.bind({
snapshotState: {
match: () => {
throw error;
},
},
});
expect(() => matcher()).toThrow(error.stack);
});