mirror of
https://github.com/SomboChea/ui
synced 2024-11-14 10:14:27 +07:00
6b322ad553
* Revert "Revert "fix(#300): correctly reference registry url from options" (#311)"
This reverts commit d955268c25
.
* fix: generate full URL from path
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
/**
|
|
* 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';
|
|
import { GlobalWithFetchMock } from 'jest-fetch-mock';
|
|
import 'mutationobserver-shim';
|
|
|
|
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 = { base: 'http://localhost' };
|
|
// @ts-ignore : Property 'VERDACCIO_API_URL' does not exist on type 'Global'.
|
|
global.VERDACCIO_API_URL = 'https://verdaccio.tld';
|
|
|
|
const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;
|
|
customGlobal.fetch = require('jest-fetch-mock');
|
|
customGlobal.fetchMock = customGlobal.fetch;
|
|
|
|
// 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();
|
|
}
|