UNPKG

2.25 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', {
4 value: true
5});
6exports.default = void 0;
7
8var _expect = _interopRequireDefault(require('expect'));
9
10var _jestSnapshot = require('jest-snapshot');
11
12function _interopRequireDefault(obj) {
13 return obj && obj.__esModule ? obj : {default: obj};
14}
15
16/**
17 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
18 *
19 * This source code is licensed under the MIT license found in the
20 * LICENSE file in the root directory of this source tree.
21 */
22
23/* eslint-disable local/prefer-spread-eventually */
24var _default = config => {
25 global.expect = _expect.default;
26
27 _expect.default.setState({
28 expand: config.expand
29 });
30
31 _expect.default.extend({
32 toMatchInlineSnapshot: _jestSnapshot.toMatchInlineSnapshot,
33 toMatchSnapshot: _jestSnapshot.toMatchSnapshot,
34 toThrowErrorMatchingInlineSnapshot:
35 _jestSnapshot.toThrowErrorMatchingInlineSnapshot,
36 toThrowErrorMatchingSnapshot: _jestSnapshot.toThrowErrorMatchingSnapshot
37 });
38
39 _expect.default.addSnapshotSerializer = _jestSnapshot.addSerializer;
40 const jasmine = global.jasmine;
41 jasmine.anything = _expect.default.anything;
42 jasmine.any = _expect.default.any;
43 jasmine.objectContaining = _expect.default.objectContaining;
44 jasmine.arrayContaining = _expect.default.arrayContaining;
45 jasmine.stringMatching = _expect.default.stringMatching;
46
47 jasmine.addMatchers = jasmineMatchersObject => {
48 const jestMatchersObject = Object.create(null);
49 Object.keys(jasmineMatchersObject).forEach(name => {
50 jestMatchersObject[name] = function (...args) {
51 // use "expect.extend" if you need to use equality testers (via this.equal)
52 const result = jasmineMatchersObject[name](null, null); // if there is no 'negativeCompare', both should be handled by `compare`
53
54 const negativeCompare = result.negativeCompare || result.compare;
55 return this.isNot
56 ? negativeCompare.apply(
57 null, // @ts-expect-error
58 args
59 )
60 : result.compare.apply(
61 null, // @ts-expect-error
62 args
63 );
64 };
65 });
66
67 _expect.default.extend(jestMatchersObject);
68 };
69};
70
71exports.default = _default;