github.com/thanos-io/thanos@v0.32.5/pkg/ui/react-app/src/setupTests.ts (about)

     1  import { configure } from 'enzyme';
     2  import Adapter from 'enzyme-adapter-react-16';
     3  import { GlobalWithFetchMock } from 'jest-fetch-mock';
     4  import 'mutationobserver-shim'; // Needed for CodeMirror.
     5  import './globals';
     6  
     7  configure({ adapter: new Adapter() });
     8  const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;
     9  customGlobal.fetch = require('jest-fetch-mock');
    10  customGlobal.fetchMock = customGlobal.fetch;
    11  
    12  // CodeMirror in the expression input requires this DOM API. When we upgrade react-scripts
    13  // and the associated Jest deps, hopefully this won't be needed anymore.
    14  document.getSelection = function () {
    15    return {
    16      addRange: function () {
    17        return;
    18      },
    19      removeAllRanges: function () {
    20        return;
    21      },
    22    };
    23  };