Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function installJestExpect() {
const expect = require('jest-matchers');
global.expect = expect;
const jasmine = global.jasmine;
jasmine.anything = expect.anything;
jasmine.any = expect.any;
jasmine.objectContaining = expect.objectContaining;
jasmine.arrayContaining = expect.arrayContaining;
jasmine.stringMatching = expect.stringMatching;
jasmine.addMatchers = (jasmineMatchersObject) => {
const jestMatchersObject = Object.create(null);
Object.keys(jasmineMatchersObject).forEach(name => {
jestMatchersObject[name] = function() {
const result = jasmineMatchersObject[name](jasmine.matchersUtil, null);
// if there is no 'negativeCompare', both should be handled by `compare`
const negativeCompare = result.negativeCompare || result.compare;
return this.isNot
? negativeCompare.apply(null, arguments)
: result.compare.apply(null, arguments);
};
});
const expect = global.expect;
expect.extend(jestMatchersObject);