UNPKG

jest-jasmine2

Version:
25 lines (23 loc) 998 B
import { jestExpect } from "@jest/expect"; //#region src/jestExpect.ts function jestExpectAdapter(config) { globalThis.expect = jestExpect; jestExpect.setState({ expand: config.expand }); const jasmine = globalThis.jasmine; jasmine.anything = jestExpect.anything; jasmine.any = jestExpect.any; jasmine.objectContaining = jestExpect.objectContaining; jasmine.arrayContaining = jestExpect.arrayContaining; jasmine.stringMatching = jestExpect.stringMatching; jasmine.addMatchers = (jasmineMatchersObject) => { const jestMatchersObject = Object.create(null); for (const name of Object.keys(jasmineMatchersObject)) jestMatchersObject[name] = function(...args) { const result = jasmineMatchersObject[name](null, null); const negativeCompare = result.negativeCompare || result.compare; return this.isNot ? negativeCompare.apply(null, args) : result.compare.apply(null, args); }; jestExpect.extend(jestMatchersObject); }; } //#endregion export { jestExpectAdapter as default };