chore: fixing typescript issues with using the new fetch

This commit is contained in:
blam
2020-10-20 10:17:31 +02:00
parent 2ef3e1f161
commit 0f76b11669
3 changed files with 14 additions and 5 deletions
+3 -2
View File
@@ -38,13 +38,14 @@
"devDependencies": {
"@backstage/cli": "^0.1.1-alpha.25",
"@backstage/dev-utils": "^0.1.1-alpha.25",
"@backstage/test-utils": "^0.1.1-alpha.25",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^10.4.1",
"@testing-library/user-event": "^12.0.7",
"@types/jest": "^26.0.7",
"@types/node": "^12.0.0",
"msw": "^0.21.2",
"cross-fetch": "^3.0.6"
"cross-fetch": "^3.0.6",
"msw": "^0.21.2"
},
"files": [
"dist"
@@ -16,10 +16,13 @@
import React from 'react';
import { render } from '@testing-library/react';
import mockFetch from 'jest-fetch-mock';
import SentryPluginPage from './SentryPluginPage';
import { ThemeProvider } from '@material-ui/core';
import { lightTheme } from '@backstage/theme';
import { msw } from '@backstage/test-utils';
import { setupServer } from 'msw/node';
import { rest } from 'msw';
import {
ApiProvider,
ApiRegistry,
@@ -31,8 +34,11 @@ const errorApi = { post: () => {} };
const ConfigApi = { getString: () => 'test' };
describe('SentryPluginPage', () => {
const server = setupServer();
msw.setupDefaultHandlers(server);
it('should render header and time switched', () => {
mockFetch.mockResponse('{}');
server.use(rest.get('/', (_req, res, ctx) => res(ctx.json({}))));
const rendered = render(
<ApiProvider
apis={ApiRegistry.from([
@@ -111,7 +111,9 @@ export async function createRouter({
const catalogRes = await fetch(`${catalogUrl}/entities/by-name/${triple}`);
if (!catalogRes.ok) {
catalogRes.body.pipe(res.status(catalogRes.status));
const catalogResText = await catalogRes.text();
res.status(catalogRes.status);
res.send(catalogResText);
return;
}