From 71b431a4e12f8d2ab27082e120183ca6679ec1a2 Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Thu, 8 Feb 2024 10:49:18 -0700 Subject: [PATCH] Import utils/chart.js early to avoid test timeouts due to React.lazy calls Signed-off-by: Taylor Smock --- .../src/components/teamsAndOrgs/tests/tasksStats.test.js | 4 ++++ frontend/src/views/tests/project.test.js | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/frontend/src/components/teamsAndOrgs/tests/tasksStats.test.js b/frontend/src/components/teamsAndOrgs/tests/tasksStats.test.js index 7bc261bfa3..ab055371d6 100644 --- a/frontend/src/components/teamsAndOrgs/tests/tasksStats.test.js +++ b/frontend/src/components/teamsAndOrgs/tests/tasksStats.test.js @@ -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, })); diff --git a/frontend/src/views/tests/project.test.js b/frontend/src/views/tests/project.test.js index 7b02149495..c7ff487d13 100644 --- a/frontend/src/views/tests/project.test.js +++ b/frontend/src/views/tests/project.test.js @@ -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(