Skip to content

Commit

Permalink
Import utils/chart.js early to avoid test timeouts due to React.lazy …
Browse files Browse the repository at this point in the history
…calls

Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Feb 12, 2024
1 parent 9377852 commit 71b431a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontend/src/components/teamsAndOrgs/tests/tasksStats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { tasksStats } from '../../../network/tests/mockData/tasksStats';
import { TasksStats } from '../tasksStats';
import userEvent from '@testing-library/user-event';

// This is a late import in a React.lazy call; it takes awhile for date-fns to resolve, so we import it here manually.
// In the event you remove it, please measure test times before ''and'' after removal.
import '../../../utils/chart';

jest.mock('react-chartjs-2', () => ({
Bar: () => null,
}));
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/views/tests/project.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ import { setupFaultyHandlers } from '../../network/tests/server';
import { projects } from '../../network/tests/mockData/projects';
import { MemoryRouter, Route, Routes } from 'react-router-dom';

// This is a late import in a React.lazy call; it takes awhile for date-fns to resolve, so we import it here manually.
// In the event you remove it, please measure test times before ''and'' after removal.
import '../../utils/chart';

// scrollTo is not implemented by jsdom; mock to avoid warnings.
window.scrollTo = jest.fn();

test('CreateProject renders ProjectCreate', async () => {
renderWithRouter(
<QueryParamProvider adapter={ReactRouter6Adapter}>
Expand Down

0 comments on commit 71b431a

Please sign in to comment.