diff --git a/x-pack/platform/plugins/shared/maps/public/classes/sources/wms_source/wms_client.js b/x-pack/platform/plugins/shared/maps/public/classes/sources/wms_source/wms_client.js index 0cbcbcd7ab8fe..2cfdefe1fdabf 100644 --- a/x-pack/platform/plugins/shared/maps/public/classes/sources/wms_source/wms_client.js +++ b/x-pack/platform/plugins/shared/maps/public/classes/sources/wms_source/wms_client.js @@ -7,7 +7,6 @@ import _ from 'lodash'; import { parseXmlString } from '../../../../common/parse_xml_string'; -import fetch from 'node-fetch'; import { parse, format } from 'url'; export class WmsClient { diff --git a/x-pack/platform/plugins/shared/maps/public/connected_components/mb_map/glyphs.test.ts b/x-pack/platform/plugins/shared/maps/public/connected_components/mb_map/glyphs.test.ts index 78df48a8c8498..d824b17c70d1e 100644 --- a/x-pack/platform/plugins/shared/maps/public/connected_components/mb_map/glyphs.test.ts +++ b/x-pack/platform/plugins/shared/maps/public/connected_components/mb_map/glyphs.test.ts @@ -26,6 +26,8 @@ jest.mock('../../kibana_services', () => ({ }, })); +const mockedFetch = jest.spyOn(global, 'fetch'); + describe('EMS enabled', () => { beforeEach(() => { // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -44,10 +46,9 @@ describe('EMS enabled', () => { describe('offline', () => { beforeAll(() => { - // eslint-disable-next-line @typescript-eslint/no-var-requires - require('node-fetch').default = () => { + mockedFetch.mockImplementation(() => { throw new Error('Simulated offline environment with no EMS access'); - }; + }); }); test('should return EMS fonts template URL before canAccessEmsFontsPromise resolves', () => { @@ -68,10 +69,9 @@ describe('EMS enabled', () => { describe('online', () => { beforeAll(() => { - // eslint-disable-next-line @typescript-eslint/no-var-requires - require('node-fetch').default = () => { - return Promise.resolve({ status: 200 }); - }; + mockedFetch.mockImplementation(() => { + return Promise.resolve(new Response(null, { status: 200 })); + }); }); test('should return EMS fonts template URL before canAccessEmsFontsPromise resolves', () => { diff --git a/x-pack/platform/plugins/shared/maps/public/connected_components/mb_map/glyphs.ts b/x-pack/platform/plugins/shared/maps/public/connected_components/mb_map/glyphs.ts index 6ce7db21f503b..2509ec1596262 100644 --- a/x-pack/platform/plugins/shared/maps/public/connected_components/mb_map/glyphs.ts +++ b/x-pack/platform/plugins/shared/maps/public/connected_components/mb_map/glyphs.ts @@ -5,7 +5,6 @@ * 2.0. */ -import fetch from 'node-fetch'; import { FONTS_API_PATH } from '../../../common/constants'; import { getDocLinks, getHttp, getEMSSettings } from '../../kibana_services';