UNPKG

@wordpress/jest-console

Version:
25 lines (24 loc) 735 B
// packages/jest-console/src/index.ts import "./matchers"; import supportedMatchers from "./supported-matchers"; var setConsoleMethodSpy = (args) => { const [methodName, matcherName] = args; const spy = jest.spyOn(console, methodName).mockName(`console.${methodName}`); function resetSpy() { spy.mockReset(); spy.assertionsNumber = 0; } function assertExpectedCalls() { if (spy.assertionsNumber === 0 && spy.mock.calls.length > 0) { expect(console).not[matcherName](); } } beforeAll(resetSpy); beforeEach(() => { assertExpectedCalls(); resetSpy(); }); afterEach(assertExpectedCalls); }; Object.entries(supportedMatchers).forEach(setConsoleMethodSpy); //# sourceMappingURL=index.js.map