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