chore(catalog): using msw instead of jest-fetch-mock

This commit is contained in:
blam
2020-10-08 21:37:45 +02:00
parent ec1ee64b73
commit cee9ca8777
3 changed files with 7 additions and 8 deletions
+1 -3
View File
@@ -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"
@@ -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 });
});
+3 -1
View File
@@ -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;