From 2d94ab999142a2f8e5dd0bec0006bdc2b2ee75a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dudak?= Date: Fri, 24 Jan 2025 15:18:32 +0100 Subject: [PATCH] [test] Speed up regression and E2E tests (#1354) --- test/e2e/TestViewer.tsx | 8 +++----- test/e2e/main.tsx | 9 +++++++-- test/regressions/TestViewer.tsx | 16 +++------------- test/regressions/main.tsx | 10 +++++++--- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/test/e2e/TestViewer.tsx b/test/e2e/TestViewer.tsx index c3b048db96..716d3ec14b 100644 --- a/test/e2e/TestViewer.tsx +++ b/test/e2e/TestViewer.tsx @@ -12,11 +12,9 @@ function TestViewer(props: { children: React.ReactNode }) { }, []); return ( - }> -
- {children} -
-
+
+ {children} +
); } diff --git a/test/e2e/main.tsx b/test/e2e/main.tsx index 1ef70589ec..a2460a0965 100644 --- a/test/e2e/main.tsx +++ b/test/e2e/main.tsx @@ -6,7 +6,7 @@ import TestViewer from './TestViewer'; import 'docs/src/styles.css'; interface Fixture { - Component: React.LazyExoticComponent>; + Component: React.ComponentType; name: string; path: string; suite: string; @@ -14,7 +14,11 @@ interface Fixture { const globbedFixtures = import.meta.glob<{ default: React.ComponentType }>( './fixtures/**/*.{js,jsx,ts,tsx}', + { + eager: true, + }, ); + const fixtures: Fixture[] = []; for (const path in globbedFixtures) { @@ -22,11 +26,12 @@ for (const path in globbedFixtures) { .replace('./', '') .replace(/\.\w+$/, '') .split('/'); + fixtures.push({ path, suite: `e2e-${suite}`, name, - Component: React.lazy(() => globbedFixtures[path]()), + Component: globbedFixtures[path].default, }); } diff --git a/test/regressions/TestViewer.tsx b/test/regressions/TestViewer.tsx index 6b6467923c..18d9309065 100644 --- a/test/regressions/TestViewer.tsx +++ b/test/regressions/TestViewer.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { useFakeTimers } from 'sinon'; function TestViewer(props: { children: React.ReactNode }) { const { children } = props; @@ -24,12 +23,6 @@ function TestViewer(props: { children: React.ReactNode }) { document.fonts.addEventListener('loading', handleFontsEvent); document.fonts.addEventListener('loadingdone', handleFontsEvent); - // Use a "real timestamp" so that we see a useful date instead of "00:00" - // eslint-disable-next-line react-hooks/rules-of-hooks -- not a React hook - const clock = useFakeTimers({ - now: new Date('Mon Aug 18 14:11:54 2014 -0500'), - toFake: ['Date'], - }); // In case the child triggered font fetching we're not ready yet. // The fonts event handler will mark the test as ready on `loadingdone` if (document.fonts.status === 'loaded') { @@ -39,7 +32,6 @@ function TestViewer(props: { children: React.ReactNode }) { return () => { document.fonts.removeEventListener('loading', handleFontsEvent); document.fonts.removeEventListener('loadingdone', handleFontsEvent); - clock.restore(); }; }, []); @@ -68,11 +60,9 @@ function TestViewer(props: { children: React.ReactNode }) { {/* eslint-disable-next-line react/no-danger */}