Fix TypeScript error in jest.setup.ts

- Update React.act mock to handle both sync and async callbacks
- Fix type compatibility with React's act function signature
- Ensures proper TypeScript compilation during build
This commit is contained in:
2025-10-15 16:09:48 +02:00
parent aaf80244d7
commit 1901dd44b8

View File

@@ -9,9 +9,12 @@ if (process.env.NODE_ENV === 'production') {
// Override React.act for production builds // Override React.act for production builds
const originalAct = React.act; const originalAct = React.act;
if (!originalAct) { if (!originalAct) {
React.act = (callback: () => void) => { React.act = (callback: () => void | Promise<void>) => {
callback(); const result = callback();
}; if (result instanceof Promise) {
return result;
}
} as typeof React.act;
} }
// Also mock the act function from react-dom/test-utils // Also mock the act function from react-dom/test-utils