Created
October 26, 2021 23:54
-
-
Save paveltretyakovru/565c17a5934a2b0700bb626842dc0a43 to your computer and use it in GitHub Desktop.
Setups for Jest tests of CRA application to fix TypeError: window.URL.createObjectURL is not a function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// react-testing-library renders your components to document.body, | |
// this adds jest-dom's custom assertions | |
import '@testing-library/jest-dom/extend-expect'; | |
import 'react-app-polyfill/ie11'; | |
import 'react-app-polyfill/stable'; | |
import 'jest-styled-components'; | |
import { configure } from 'enzyme'; | |
import Adapter from 'enzyme-adapter-react-16'; | |
// fix to TypeError: window.URL.createObjectURL is not a function | |
jest.mock('mapbox-gl/dist/mapbox-gl', () => ({ | |
GeolocateControl: jest.fn(), | |
Map: jest.fn(() => ({ | |
addControl: jest.fn(), | |
on: jest.fn(), | |
remove: jest.fn(), | |
})), | |
NavigationControl: jest.fn(), | |
})); | |
configure({ adapter: new Adapter() }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment