2019-10-28 10:09:48 -07:00
|
|
|
import { configure } from 'enzyme';
|
2021-08-30 05:13:58 -07:00
|
|
|
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
2019-11-02 02:27:36 -07:00
|
|
|
import { GlobalWithFetchMock } from 'jest-fetch-mock';
|
2021-03-23 15:55:52 -07:00
|
|
|
import 'mutationobserver-shim'; // Needed for CodeMirror.
|
2019-10-28 10:09:48 -07:00
|
|
|
import './globals';
|
2021-09-07 07:34:12 -07:00
|
|
|
import 'jest-canvas-mock';
|
2019-10-28 10:09:48 -07:00
|
|
|
|
|
|
|
configure({ adapter: new Adapter() });
|
2019-11-02 02:27:36 -07:00
|
|
|
const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;
|
|
|
|
customGlobal.fetch = require('jest-fetch-mock');
|
|
|
|
customGlobal.fetchMock = customGlobal.fetch;
|
2021-03-23 15:55:52 -07:00
|
|
|
|
|
|
|
// CodeMirror in the expression input requires this DOM API. When we upgrade react-scripts
|
|
|
|
// and the associated Jest deps, hopefully this won't be needed anymore.
|
2021-09-03 08:41:20 -07:00
|
|
|
document.getSelection = function () {
|
2021-03-23 15:55:52 -07:00
|
|
|
return {
|
2021-09-03 08:41:20 -07:00
|
|
|
addRange: function () {
|
2021-03-23 15:55:52 -07:00
|
|
|
return;
|
|
|
|
},
|
2021-09-03 08:41:20 -07:00
|
|
|
removeAllRanges: function () {
|
2021-03-23 15:55:52 -07:00
|
|
|
return;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|