/
snapshot.test.js
42 lines (38 loc) · 1.01 KB
/
snapshot.test.js
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) Facebook, Inc. and its affiliates. 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.
*
* @emails oncall+jsinfra
*/
'use strict';
describe('snapshot', () => {
it('works with plain objects and the title has `escape` characters', () => {
const test = {
a: 1,
b: '2',
c: 'three`',
};
expect(test).toMatchSnapshot();
test.d = '4';
expect(test).toMatchSnapshot();
});
it('is not influenced by previous counter', () => {
const test = {
a: 43,
b: '43',
c: 'fourtythree',
};
expect(test).toMatchSnapshot();
});
it('cannot be used with .not', () => {
expect(() => expect('').not.toMatchSnapshot()).toThrow(
'.not cannot be used with snapshot matchers'
);
});
// Issue reported here: https://github.com/facebook/jest/issues/2969
it('works with \\r\\n', () => {
expect('<div>\r\n</div>').toMatchSnapshot();
});
});