diff --git a/vitest.setup.ts b/vitest.setup.ts index 7b0828bfa8..bc1f5663d0 100644 --- a/vitest.setup.ts +++ b/vitest.setup.ts @@ -1 +1,28 @@ import '@testing-library/jest-dom'; +import { cleanup } from '@testing-library/react'; + +// Basic cleanup after each test +afterEach(() => { + cleanup(); +}); + +// Simple console error handler for React 18 warnings +const originalError = console.error; +beforeAll(() => { + console.error = (...args: unknown[]) => { + const firstArg = args[0]; + if ( + typeof firstArg === 'string' && + /Warning: ReactDOM.render is no longer supported in React 18./.test( + firstArg, + ) + ) { + return; + } + originalError.call(console, ...args); + }; +}); + +afterAll(() => { + console.error = originalError; +});