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
|
// 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
|
||||||
|
|||||||
Reference in New Issue
Block a user