refactor: improve test structure for Bun compatibility
- Update all test files to use named mock variables instead of inline mocks - Clear mock history in beforeEach instead of using mock.restore() - Add default mock implementations stored at module level - Document that tests should not use --randomize flag due to mock.module() limitations - All 89 unit tests pass consistently without randomization
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Setup file for Bun test runner to provide DOM environment
|
||||
import { JSDOM } from 'jsdom';
|
||||
import '@testing-library/jest-dom';
|
||||
import { act } from '@testing-library/react';
|
||||
|
||||
const dom = new JSDOM('<!DOCTYPE html><html><body></body></html>', {
|
||||
url: 'http://localhost',
|
||||
@@ -10,3 +11,9 @@ const dom = new JSDOM('<!DOCTYPE html><html><body></body></html>', {
|
||||
(global as any).window = dom.window;
|
||||
(global as any).document = dom.window.document;
|
||||
(global as any).navigator = dom.window.navigator;
|
||||
|
||||
// Extend global act to handle async operations
|
||||
const originalAct = act;
|
||||
(global as any).act = async (callback: () => Promise<void> | void) => {
|
||||
return originalAct(callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user