jest-jasmine2
Version:
60 lines (55 loc) • 2.07 kB
JavaScript
/*!
* /**
* * Copyright (c) Meta Platforms, Inc. and affiliates.
* *
* * This source code is licensed under the MIT license found in the
* * LICENSE file in the root directory of this source tree.
* * /
*/
/******/ (() => { // webpackBootstrap
/******/ "use strict";
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
(() => {
var exports = __webpack_exports__;
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = jestExpectAdapter;
var _expect = require("@jest/expect");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/* eslint-disable local/prefer-spread-eventually */
function jestExpectAdapter(config) {
globalThis.expect = _expect.jestExpect;
_expect.jestExpect.setState({
expand: config.expand
});
const jasmine = globalThis.jasmine;
jasmine.anything = _expect.jestExpect.anything;
jasmine.any = _expect.jestExpect.any;
jasmine.objectContaining = _expect.jestExpect.objectContaining;
jasmine.arrayContaining = _expect.jestExpect.arrayContaining;
jasmine.stringMatching = _expect.jestExpect.stringMatching;
jasmine.addMatchers = jasmineMatchersObject => {
const jestMatchersObject = Object.create(null);
for (const name of Object.keys(jasmineMatchersObject)) {
jestMatchersObject[name] = function (...args) {
// use "expect.extend" if you need to use equality testers (via this.equal)
const result = jasmineMatchersObject[name](null, null);
// if there is no 'negativeCompare', both should be handled by `compare`
const negativeCompare = result.negativeCompare || result.compare;
return this.isNot ? negativeCompare.apply(null, args) : result.compare.apply(null, args);
};
}
_expect.jestExpect.extend(jestMatchersObject);
};
}
})();
module.exports = __webpack_exports__;
/******/ })()
;