core-components: avoid logging in GaugeCard test

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-09-11 16:52:07 +02:00
parent 50d6c7e07e
commit 3742ccbfc3
@@ -15,7 +15,7 @@
*/
import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { renderInTestApp, withLogCollector } from '@backstage/test-utils';
import { GaugeCard } from './GaugeCard';
@@ -40,7 +40,12 @@ describe('<GaugeCard />', () => {
it('handles invalid numbers', async () => {
const badProps = { title: 'Tingle upgrade', progress: 'hejjo' } as any;
const { getByText } = await renderInTestApp(<GaugeCard {...badProps} />);
expect(getByText(/N\/A.*/)).toBeInTheDocument();
const { error } = await withLogCollector(async () => {
const { getByText } = await renderInTestApp(<GaugeCard {...badProps} />);
expect(getByText(/N\/A.*/)).toBeInTheDocument();
});
expect(error).toEqual([
expect.stringMatching(/^Warning: `NaN` is an invalid value/),
]);
});
});