How to use the jest-fetch-mock.enableMocks function in jest-fetch-mock

To help you get started, we’ve selected a few jest-fetch-mock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github influxdata / influxdb / ui / jestSetup.ts View on Github external
declare global {
  interface Window {
    flushAllPromises: () => Promise
    MutationObserver: MutationObserver
  }
}

// Adds MutationObserver as a polyfill for testing
window.MutationObserver = MutationObserver

window.flushAllPromises = async () => {
  return new Promise(resolve => setImmediate(resolve))
}

// mocks and stuff
fetchMock.enableMocks()
jest.mock('honeybadger-js', () => () => null)

// cleans up state between @testing-library/react tests
afterEach(() => {
  cleanup()
  fetchMock.resetMocks()
})
github ShadOoW / web-starter-kit / .setup-tests.js View on Github external
import '@testing-library/jest-dom/extend-expect';
import 'jest-styled-components';
require('jest-fetch-mock').enableMocks();