Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Replace fetch-mock-jest with jest-fetch-mock (#5920)

christof-wittreich25365670f055
diff --git a/jest.config.js b/jest.config.js
index 840e19455..4213b4e97 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -1,7 +1,8 @@
module.exports = {
setupFiles: [
'jest-canvas-mock',
- 'jsdom-worker'
+ 'jsdom-worker',
+ './setupJest.js'
],
moduleDirectories: [
'node_modules'
diff --git a/package-lock.json b/package-lock.json
index 19a811aa7..ff52ec6a9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -30,7 +30,6 @@
"element-resize-detector": "^1.2.4",
"elm-pep": "^1.0.6",
"eslint-plugin-react-hooks": "^5.2.0",
- "fetch-mock-jest": "^1.5.1",
"file-saver": "^2.0.5",
"geographiclib-geodesic": "^2.1.1",
"history": "^5.3.0",
@@ -114,6 +113,7 @@
"jest": "^29.7.0",
"jest-canvas-mock": "^2.5.2",
"jest-environment-jsdom": "^29.7.0",
+ "jest-fetch-mock": "^3.0.3",
"mini-css-extract-plugin": "^2.9.2",
"node-dir": "^0.1.17",
"node-fetch": "^2.6.9",
@@ -151,6 +151,7 @@
},
"node_modules/@ampproject/remapping": {
"version": "2.3.0",
+ "dev": true,
"license": "Apache-2.0",
"dependencies": {
"@jridgewell/gen-mapping": "^0.3.5",
@@ -178,6 +179,7 @@
"version": "7.27.2",
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.27.2.tgz",
"integrity": "sha512-TUtMJYRPyUb/9aU8f3K0mjmjf6M9N5Woshn2CS6nqJSeJtTtQcpLUXjGt9vbF8ZGff0El99sWkLgzwW3VXnxZQ==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">=6.9.0"
@@ -187,6 +189,7 @@
"version": "7.27.4",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.27.4.tgz",
"integrity": "sha512-bXYxrXFubeYdvB0NhD/NBB3Qi6aZeV20GOWVI47t2dkecCEoneR4NPVcb7abpXDEvejgrUfFtG6vG/zxAKmg+g==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"@ampproject/remapping": "^2.2.0",
@@ -265,6 +268,7 @@
"version": "7.27.2",
"resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz",
"integrity": "sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"@babel/compat-data": "^7.27.2",
@@ -363,6 +367,7 @@
"version": "7.27.3",
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.27.3.tgz",
"integrity": "sha512-dSOvYwvyLsWBeIRyOeHXp5vPj5l1I011r52FM1+r1jCERv+aFXYk4whgQccYEGYxK2H3ZAIA8nuPkQ0HaUo3qg==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"@babel/helper-module-imports": "^7.27.1",
@@ -471,6 +476,7 @@
"version": "7.27.1",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz",
"integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">=6.9.0"
@@ -495,6 +501,7 @@
"version": "7.27.4",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.27.4.tgz",
"integrity": "sha512-Y+bO6U+I7ZKaM5G5rDUZiYfUvQPUibYmAFe7EnKdnKBbVXDZxvp+MWOH5gYciY0EPk4EScsuFMQBbEfpdRKSCQ==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"@babel/template": "^7.27.2",
@@ -5498,6 +5505,7 @@
},
"node_modules/convert-source-map": {
"version": "2.0.0",
+ "dev": true,
"license": "MIT"
},
"node_modules/cookie": {
@@ -5529,15 +5537,6 @@
"toggle-selection": "^1.0.6"
}
},
- "node_modules/core-js": {
- "version": "3.41.0",
- "hasInstallScript": true,
- "license": "MIT",
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/core-js"
- }
- },
"node_modules/core-js-compat": {
"version": "3.41.0",
"dev": true,
@@ -5627,6 +5626,16 @@
"yarn": ">=1"
}
},
+ "node_modules/cross-fetch": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.2.0.tgz",
+ "integrity": "sha512-Q+xVJLoGOeIMXZmbUK4HYk+69cQH6LudR0Vu/pRm2YlU/hDV9CiS0gKUMaWY5f2NeUH9C1nV3bsTlCo0FsTV1Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "node-fetch": "^2.7.0"
+ }
+ },
"node_modules/cross-spawn": {
"version": "7.0.6",
"license": "MIT",
@@ -7888,59 +7897,6 @@
"bser": "2.1.1"
}
},
- "node_modules/fetch-mock": {
- "version": "9.11.0",
- "license": "MIT",
- "dependencies": {
- "@babel/core": "^7.0.0",
- "@babel/runtime": "^7.0.0",
- "core-js": "^3.0.0",
- "debug": "^4.1.1",
- "glob-to-regexp": "^0.4.0",
- "is-subset": "^0.1.1",
- "lodash.isequal": "^4.5.0",
- "path-to-regexp": "^2.2.1",
- "querystring": "^0.2.0",
- "whatwg-url": "^6.5.0"
- },
- "engines": {
- "node": ">=4.0.0"
- },
- "funding": {
- "type": "charity",
- "url": "https://www.justgiving.com/refugee-support-europe"
- },
- "peerDependencies": {
- "node-fetch": "*"
- },
- "peerDependenciesMeta": {
- "node-fetch": {
- "optional": true
- }
- }
- },
- "node_modules/fetch-mock-jest": {
- "version": "1.5.1",
- "license": "MIT",
- "dependencies": {
- "fetch-mock": "^9.11.0"
- },
- "engines": {
- "node": ">=8.0.0"
- },
- "funding": {
- "type": "charity",
- "url": "https://www.justgiving.com/refugee-support-europe"
- },
- "peerDependencies": {
- "node-fetch": "*"
- },
- "peerDependenciesMeta": {
- "node-fetch": {
- "optional": true
- }
- }
- },
"node_modules/file-entry-cache": {
"version": "6.0.1",
"license": "MIT",
@@ -8227,6 +8183,7 @@
},
"node_modules/gensync": {
"version": "1.0.0-beta.2",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">=6.9.0"
@@ -9581,10 +9538,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/is-subset": {
- "version": "0.1.1",
- "license": "MIT"
- },
"node_modules/is-symbol": {
"version": "1.1.1",
"dev": true,
@@ -10120,6 +10073,17 @@
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
+ "node_modules/jest-fetch-mock": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/jest-fetch-mock/-/jest-fetch-mock-3.0.3.tgz",
+ "integrity": "sha512-Ux1nWprtLrdrH4XwE7O7InRY6psIi3GOsqNESJgMJ+M5cv4A8Lh7SN9d2V2kKRZ8ebAfcd1LNyZguAOb6JiDqw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "cross-fetch": "^3.0.4",
+ "promise-polyfill": "^8.1.3"
+ }
+ },
"node_modules/jest-get-type": {
"version": "29.6.3",
"dev": true,
@@ -10662,6 +10626,7 @@
},
"node_modules/json5": {
"version": "2.2.3",
+ "dev": true,
"license": "MIT",
"bin": {
"json5": "lib/cli.js"
@@ -10889,10 +10854,6 @@
"version": "4.5.0",
"license": "MIT"
},
- "node_modules/lodash.isequal": {
- "version": "4.5.0",
- "license": "MIT"
- },
"node_modules/lodash.isplainobject": {
"version": "4.0.6",
"dev": true,
@@ -10909,10 +10870,6 @@
"version": "4.6.2",
"license": "MIT"
},
- "node_modules/lodash.sortby": {
- "version": "4.7.0",
- "license": "MIT"
- },
"node_modules/lodash.truncate": {
"version": "4.4.2",
"dev": true,
@@ -10937,6 +10894,7 @@
},
"node_modules/lru-cache": {
"version": "5.1.1",
+ "dev": true,
"license": "ISC",
"dependencies": {
"yallist": "^3.0.2"
@@ -12252,6 +12210,7 @@
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz",
"integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">=16"
@@ -13096,6 +13055,13 @@
"wkt-parser": "^1.5.1"
}
},
+ "node_modules/promise-polyfill": {
+ "version": "8.3.0",
+ "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.3.0.tgz",
+ "integrity": "sha512-H5oELycFml5yto/atYqmjyigJoAo3+OXwolYiH7OfQuYlAqhxNvTfiNMbV9hsC6Yp83yE5r2KTVmtrG6R9i6Pg==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/prompts": {
"version": "2.4.2",
"dev": true,
@@ -13183,13 +13149,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/querystring": {
- "version": "0.2.1",
- "license": "MIT",
- "engines": {
- "node": ">=0.4.x"
- }
- },
"node_modules/querystringify": {
"version": "2.2.0",
"dev": true,
@@ -14399,6 +14358,7 @@
},
"node_modules/semver": {
"version": "7.5.4",
+ "dev": true,
"license": "ISC",
"dependencies": {
"lru-cache": "^6.0.0"
@@ -14412,6 +14372,7 @@
},
"node_modules/semver/node_modules/lru-cache": {
"version": "6.0.0",
+ "dev": true,
"license": "ISC",
"dependencies": {
"yallist": "^4.0.0"
@@ -14422,6 +14383,7 @@
},
"node_modules/semver/node_modules/yallist": {
"version": "4.0.0",
+ "dev": true,
"license": "ISC"
},
"node_modules/send": {
@@ -15993,13 +15955,6 @@
"node": ">=16"
}
},
- "node_modules/tr46": {
- "version": "1.0.1",
- "license": "MIT",
- "dependencies": {
- "punycode": "^2.1.0"
- }
- },
"node_modules/tree-changes": {
"version": "0.11.3",
"license": "MIT",
@@ -17331,19 +17286,6 @@
"node": ">=18"
}
},
- "node_modules/whatwg-url": {
- "version": "6.5.0",
- "license": "MIT",
- "dependencies": {
- "lodash.sortby": "^4.7.0",
- "tr46": "^1.0.1",
- "webidl-conversions": "^4.0.2"
- }
- },
- "node_modules/whatwg-url/node_modules/webidl-conversions": {
- "version": "4.0.2",
- "license": "BSD-2-Clause"
- },
"node_modules/which": {
"version": "2.0.2",
"license": "ISC",
@@ -17641,6 +17583,7 @@
},
"node_modules/yallist": {
"version": "3.1.1",
+ "dev": true,
"license": "ISC"
},
"node_modules/yaml": {
diff --git a/package.json b/package.json
index 7c7a7e121..f55b7dc14 100644
--- a/package.json
+++ b/package.json
@@ -113,6 +113,7 @@
"jest": "^29.7.0",
"jest-canvas-mock": "^2.5.2",
"jest-environment-jsdom": "^29.7.0",
+ "jest-fetch-mock": "^3.0.3",
"mini-css-extract-plugin": "^2.9.2",
"node-dir": "^0.1.17",
"node-fetch": "^2.6.9",
@@ -165,7 +166,6 @@
"element-resize-detector": "^1.2.4",
"elm-pep": "^1.0.6",
"eslint-plugin-react-hooks": "^5.2.0",
- "fetch-mock-jest": "^1.5.1",
"file-saver": "^2.0.5",
"geographiclib-geodesic": "^2.1.1",
"history": "^5.3.0",
diff --git a/setupJest.js b/setupJest.js
new file mode 100644
index 000000000..167ff3a7a
--- /dev/null
+++ b/setupJest.js
@@ -0,0 +1,3 @@
+const fetchMock = require('jest-fetch-mock')
+fetchMock.enableMocks()
+fetchMock.dontMock()
diff --git a/web/js/fixtures.js b/web/js/fixtures.js
index 22df5cfe4..a696a2a93 100644
--- a/web/js/fixtures.js
+++ b/web/js/fixtures.js
@@ -363,6 +363,9 @@ fixtures.config = function() {
endDate: '2019-09-24T23:54:00Z',
source: 'GIBS:geographic:nrt',
matrixSet: '250m',
+ daynight: [
+ 'day',
+ ],
conceptIds: [
{
shortName: 'VJ102IMG_NRT',
diff --git a/web/js/map/granule/granule-layer-builder.test.js b/web/js/map/granule/granule-layer-builder.test.js
index 5ef48a57e..b93d4730e 100644
--- a/web/js/map/granule/granule-layer-builder.test.js
+++ b/web/js/map/granule/granule-layer-builder.test.js
@@ -1,6 +1,5 @@
import configureMockStore from 'redux-mock-store';
import { thunk } from 'redux-thunk';
-import fetchMock from 'fetch-mock-jest';
import fixtures from '../../fixtures';
import layerbuilder from '../layerbuilder';
import granuleLayerBuilder from './granule-layer-builder';
@@ -9,12 +8,10 @@ import granuleLayerBuilder from './granule-layer-builder';
// import { ADD_GRANULE_LAYER_DATES } from '../../modules/layers/constants';
const mockBaseCmrApi = 'mock.cmr.api/';
-const queryString = '?bounding_box=-180%2C-65%2C180%2C65&shortName=VJ102IMG&day_night_flag=DAY&temporal=2019-09-23T20%3A54%3A00.000Z%2C2019-09-24T12%3A54%3A00.000Z&pageSize=500';
+const queryString = '?bounding_box=-180%2C-65%2C180%2C65&shortName=VJ102IMG&day_night_flag=day&temporal=2019-09-23T20%3A54%3A00.000Z%2C2019-09-24T12%3A54%3A00.000Z&pageSize=500';
+const queryString2 = '?bounding_box=-180%2C-65%2C180%2C65&shortName=VJ102IMG_NRT&day_night_flag=day&temporal=2019-09-23T20%3A54%3A00.000Z%2C2019-09-24T12%3A54%3A00.000Z&pageSize=500';
const cmrGranules = require('../../../mock/cmr_granules.json');
-fetchMock.mock(`${mockBaseCmrApi}granules.json${queryString}`, cmrGranules)
- .mock('*', 404);
-
const mockStore = configureMockStore([thunk]);
const config = fixtures.config();
const { cache } = fixtures;
@@ -42,6 +39,19 @@ describe('granule layer builder', () => {
const { createLayerWMTS } = layerbuilder(config, cache, store);
const { getGranuleLayer } = granuleLayerBuilder(cache, store, createLayerWMTS);
createGranuleLayer = getGranuleLayer;
+ fetch.resetMocks();
+ fetch.mockResponse((req) => {
+ if (req.url === `${mockBaseCmrApi}granules.json${queryString}` || req.url === `${mockBaseCmrApi}granules.json${queryString2}`) {
+ return Promise.resolve({
+ status: 200,
+ body: cmrGranules,
+ });
+ }
+ return Promise.resolve({
+ status: 404,
+ body: JSON.stringify({ error: 'Not found' }),
+ });
+ });
});
// TODO: fix fetchMock in jest v28+
diff --git a/web/js/modules/link/actions.test.js b/web/js/modules/link/actions.test.js
index d8a352233..26d573ffc 100644
--- a/web/js/modules/link/actions.test.js
+++ b/web/js/modules/link/actions.test.js
@@ -1,7 +1,6 @@
import { TextEncoder, TextDecoder } from 'util';
import configureMockStore from 'redux-mock-store';
import { thunk } from 'redux-thunk';
-import fetchMock from 'fetch-mock-jest';
import * as actions from './actions';
import * as constants from './constants';
@@ -14,24 +13,17 @@ const mockStore = configureMockStore(middlewares);
const ERROR_MESSAGE = 'There was an error';
// throw new Error(ERROR_MESSAGE);
describe('Short Link request action', () => {
- afterEach(() => {
- fetchMock.restore();
+ beforeEach(() => {
+ fetch.resetMocks();
});
test(
`creates ${
- constants.REQUEST_SHORT_LINK_SUCESSS
+ constants.REQUEST_SHORT_LINK_SUCCESS
} when short link is complete [link-actions-request-short-link]`,
() => {
const loc = 'mock/';
- fetchMock.getOnce(loc, {
- body: constants.MOCK_SHORT_LINK_RESPONSE,
- headers: {
- 'content-type': 'application/json',
- 'Access-Control-Allow-Origin': '*',
- 'Access-Control-Allow-Headers': 'Content-Type',
- },
- });
+ fetch.mockResponseOnce(JSON.stringify(constants.MOCK_SHORT_LINK_RESPONSE));
const expectedActions = [
{ type: constants.REQUEST_SHORT_LINK_START },
{
@@ -49,9 +41,7 @@ describe('Short Link request action', () => {
);
test(`creates ${constants.REQUEST_SHORT_LINK_FAILURE} Action [link-actions-failure]`, () => {
const loc = 'mock/';
- fetchMock.mock(loc, {
- throws: ERROR_MESSAGE,
- });
+ fetch.mockRejectOnce(ERROR_MESSAGE);
const expectedActions = [
{ type: constants.REQUEST_SHORT_LINK_START },
{
diff --git a/web/js/modules/modal/actions.test.js b/web/js/modules/modal/actions.test.js
index 5de62d588..fbcae559e 100644
--- a/web/js/modules/modal/actions.test.js
+++ b/web/js/modules/modal/actions.test.js
@@ -1,7 +1,6 @@
import { TextEncoder, TextDecoder } from 'util';
import configureMockStore from 'redux-mock-store';
import { thunk } from 'redux-thunk';
-import fetchMock from 'fetch-mock-jest';
import {
openBasicContent,
openCustomContent,
@@ -86,19 +85,12 @@ describe('Modal open actions', () => {
);
});
describe('Template fetching', () => {
- afterEach(() => {
- fetchMock.restore();
+ beforeEach(() => {
+ fetch.resetMocks();
});
test('triggers start and success action types [modal-actions-success]', () => {
const loc = 'mock/';
- fetchMock.getOnce(loc, {
- body: constants.ABOUT_MOCK_RESPONSE,
- headers: {
- 'content-type': 'text/html',
- 'Access-Control-Allow-Origin': '*',
- 'Access-Control-Allow-Headers': 'Content-Type',
- },
- });
+ fetch.mockResponseOnce(constants.ABOUT_MOCK_RESPONSE);
const expectedActions = [
{ type: constants.TEMPLATE_REQUEST_START },
{
@@ -115,9 +107,7 @@ describe('Template fetching', () => {
});
test(`creates ${constants.TEMPLATE_REQUEST_FAILURE} Action [modal-actions-failure]`, () => {
const loc = 'mock/';
- fetchMock.mock(loc, {
- throws: ERROR_MESSAGE,
- });
+ fetch.mockRejectOnce(ERROR_MESSAGE);
const expectedActions = [
{ type: constants.TEMPLATE_REQUEST_START },
{
diff --git a/web/js/modules/notifications/actions.test.js b/web/js/modules/notifications/actions.test.js
index 36e2677c9..e55a9b247 100644
--- a/web/js/modules/notifications/actions.test.js
+++ b/web/js/modules/notifications/actions.test.js
@@ -1,7 +1,6 @@
import { TextEncoder, TextDecoder } from 'util';
import configureMockStore from 'redux-mock-store';
import { thunk } from 'redux-thunk';
-import fetchMock from 'fetch-mock-jest';
import * as actions from './actions';
import * as constants from './constants';
@@ -13,19 +12,12 @@ const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
const ERROR_MESSAGE = 'There was an error';
describe('Notification fetch action', () => {
- afterEach(() => {
- fetchMock.restore();
+ beforeEach(() => {
+ fetch.resetMocks();
});
test('triggers start and success action types [notifications-actions-success]', () => {
const loc = 'mock/';
- fetchMock.getOnce(loc, {
- body: constants.MOCK_RESPONSE,
- headers: {
- 'content-type': 'application/json',
- 'Access-Control-Allow-Origin': '*',
- 'Access-Control-Allow-Headers': 'Content-Type',
- },
- });
+ fetch.mockResponseOnce(JSON.stringify(constants.MOCK_RESPONSE));
const expectedActions = [
{ type: constants.REQUEST_NOTIFICATIONS_START },
{
@@ -42,9 +34,7 @@ describe('Notification fetch action', () => {
});
test(`creates ${constants.REQUEST_NOTIFICATIONS_FAILURE} Action [notifications-actions-failure]`, () => {
const loc = 'mock/';
- fetchMock.mock(loc, {
- throws: ERROR_MESSAGE,
- });
+ fetch.mockRejectOnce(ERROR_MESSAGE);
const expectedActions = [
{ type: constants.REQUEST_NOTIFICATIONS_START },
{
diff --git a/web/js/modules/palettes/actions.test.js b/web/js/modules/palettes/actions.test.js
index 01a1516ad..556d75ecd 100644
--- a/web/js/modules/palettes/actions.test.js
+++ b/web/js/modules/palettes/actions.test.js
@@ -1,7 +1,6 @@
import { TextEncoder, TextDecoder } from 'util';
import configureMockStore from 'redux-mock-store';
import { thunk } from 'redux-thunk';
-import fetchMock from 'fetch-mock-jest';
import { assign, cloneDeep } from 'lodash';
import update from 'immutability-helper';
import {
@@ -33,19 +32,11 @@ const ERROR_MESSAGE = 'There was an error';
describe('Palette terra-aod fetching with requestPalette action [palettes-actions-request-palette]', () => {
const mockStore = configureMockStore(middlewares);
- afterEach(() => {
- fetchMock.restore();
+ beforeEach(() => {
+ fetch.resetMocks();
});
- const loc = 'config/palettes/terra-aod.json';
test(`test ${REQUEST_PALETTE_SUCCESS}`, () => {
- fetchMock.getOnce(loc, {
- body: JSON.stringify(config.palettes.rendered['terra-aod']),
- headers: {
- 'content-type': 'application/json',
- 'Access-Control-Allow-Origin': '*',
- 'Access-Control-Allow-Headers': 'Content-Type',
- },
- });
+ fetch.mockResponseOnce(JSON.stringify(config.palettes.rendered['terra-aod']));
const expectedActions = [
{ type: REQUEST_PALETTE_START, id: 'terra-aod' },
{
@@ -60,9 +51,7 @@ describe('Palette terra-aod fetching with requestPalette action [palettes-action
});
});
test(`Test ${REQUEST_PALETTE_FAILURE} [palettes-actions-failure]`, () => {
- fetchMock.mock(loc, {
- throws: ERROR_MESSAGE,
- });
+ fetch.mockReject(ERROR_MESSAGE);
const expectedActions = [
{ type: REQUEST_PALETTE_START, id: 'terra-aod' },
{
@@ -84,8 +73,8 @@ describe('Test lookup actions [palettes-actions-lookup]', () => {
const stateWithLayers = update(state, {
layers: { active: { $set: layers } },
});
- afterEach(() => {
- fetchMock.restore();
+ beforeEach(() => {
+ fetch.resetMocks();
});
test(`test ${setThresholdRangeAndSquash} action with min equal to 1`, () => {
const store = mockStore(stateWithLayers);