diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index ea270b6fe9..e4b9fda24a 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -50,11 +50,9 @@ "@testing-library/user-event": "^12.0.7", "@types/jest": "^26.0.7", "@types/node": "^12.0.0", - "jest-fetch-mock": "^3.0.3", "msw": "^0.20.5", "node-fetch": "^2.6.1", - "react-test-renderer": "^16.13.1", - "whatwg-fetch": "^3.4.0" + "react-test-renderer": "^16.13.1" }, "files": [ "dist" diff --git a/plugins/catalog/src/api/CatalogClient.test.ts b/plugins/catalog/src/api/CatalogClient.test.ts index 832a114276..7c0123317d 100644 --- a/plugins/catalog/src/api/CatalogClient.test.ts +++ b/plugins/catalog/src/api/CatalogClient.test.ts @@ -19,18 +19,17 @@ import { setupServer } from 'msw/node'; import { CatalogClient } from './CatalogClient'; import { Entity } from '@backstage/catalog-model'; import { UrlPatternDiscovery } from '@backstage/core'; +import { msw } from '@backstage/test-utils'; const server = setupServer(); const mockBaseUrl = 'http://backstage:9191/i-am-a-mock-base'; const discoveryApi = UrlPatternDiscovery.compile(mockBaseUrl); describe('CatalogClient', () => { - beforeAll(() => server.listen({ onUnhandledRequest: 'error' })); - afterEach(() => server.resetHandlers()); - afterAll(() => server.close()); - let client = new CatalogClient({ discoveryApi }); + msw.setupDefaultHandlers(server); + beforeEach(() => { client = new CatalogClient({ discoveryApi }); }); diff --git a/plugins/catalog/src/setupTests.ts b/plugins/catalog/src/setupTests.ts index 4016f3f38e..aef3b98817 100644 --- a/plugins/catalog/src/setupTests.ts +++ b/plugins/catalog/src/setupTests.ts @@ -14,5 +14,7 @@ * limitations under the License. */ +import fetch from 'node-fetch'; import '@testing-library/jest-dom'; -import 'whatwg-fetch'; + +global.fetch = fetch as any;