2019-06-20 19:37:28 +07:00
|
|
|
/**
|
|
|
|
* Setup configuration for Jest
|
|
|
|
* This file includes global settings for the JEST environment.
|
|
|
|
*/
|
|
|
|
import 'raf/polyfill';
|
|
|
|
import { configure } from 'enzyme';
|
|
|
|
import Adapter from 'enzyme-adapter-react-16';
|
2019-08-25 19:34:27 +07:00
|
|
|
import { GlobalWithFetchMock } from 'jest-fetch-mock';
|
2019-06-20 19:37:28 +07:00
|
|
|
|
|
|
|
// @ts-ignore : Only a void function can be called with the 'new' keyword
|
|
|
|
configure({ adapter: new Adapter() });
|
|
|
|
|
|
|
|
// @ts-ignore : Property '__APP_VERSION__' does not exist on type 'Global'.
|
|
|
|
global.__APP_VERSION__ = '1.0.0';
|
|
|
|
// @ts-ignore : Property '__VERDACCIO_BASENAME_UI_OPTIONS' does not exist on type 'Global'.
|
|
|
|
global.__VERDACCIO_BASENAME_UI_OPTIONS = {};
|
|
|
|
|
2019-11-01 13:18:55 +07:00
|
|
|
global.VERDACCIO_API_URL = 'https://verdaccio.tld';
|
|
|
|
|
2019-08-25 19:34:27 +07:00
|
|
|
const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;
|
|
|
|
customGlobal.fetch = require('jest-fetch-mock');
|
|
|
|
customGlobal.fetchMock = customGlobal.fetch;
|
|
|
|
|
2019-06-20 19:37:28 +07:00
|
|
|
// mocking few DOM methods
|
|
|
|
// @ts-ignore : Property 'document' does not exist on type 'Global'.
|
|
|
|
if (global.document) {
|
|
|
|
// @ts-ignore : Type 'Mock<{ selectNodeContents: () => void; }, []>' is not assignable to type '() => Range'.
|
|
|
|
document.createRange = jest.fn((): void => ({
|
|
|
|
selectNodeContents: (): void => {},
|
|
|
|
}));
|
|
|
|
document.execCommand = jest.fn();
|
|
|
|
}
|