Chore: Fix flaky test in SpanGraph/index.test.tsx (#61009)

This commit is contained in:
Hamas Shafiq 2023-01-10 14:23:00 +00:00 committed by GitHub
parent ad1813da27
commit 2af79535bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -50,4 +50,11 @@ describe('<TickLabels>', () => {
expect(tick).toHaveStyle(`left: ${pos};`);
});
});
it('shows the correct value above each tick', () => {
expect(screen.getByText('0μs')).toBeTruthy();
expect(screen.getByText('1.25ms')).toBeTruthy();
expect(screen.getByText('2.5ms')).toBeTruthy();
expect(screen.getByText('3.75ms')).toBeTruthy();
expect(screen.getByText('5ms')).toBeTruthy();
});
});

View File

@ -19,8 +19,6 @@ import traceGenerator from '../../demo/trace-generators';
import transformTraceData from '../../model/transform-trace-data';
import { polyfill as polyfillAnimationFrame } from '../../utils/test/requestAnimationFrame';
import TickLabels from './TickLabels';
import SpanGraph, { SpanGraphProps, TIMELINE_TICK_INTERVAL } from './index';
describe('<SpanGraph>', () => {
@ -60,12 +58,4 @@ describe('<SpanGraph>', () => {
const tickLabelsDiv = screen.getByTestId('TickLabels');
expect(getAllByTestId(tickLabelsDiv, 'tick').length).toBe(TIMELINE_TICK_INTERVAL + 1);
});
it('renders <TickLabels /> with the correct value next to each tick', () => {
render(<TickLabels numTicks={5} duration={1} />);
expect(screen.getByText(/0.2/)).toBeTruthy();
expect(screen.getByText(/0.4/)).toBeTruthy();
expect(screen.getByText(/0.6/)).toBeTruthy();
expect(screen.getByText(/0.8/)).toBeTruthy();
});
});