2025-04-11 17:53:18 +08:00
|
|
|
import '@testing-library/jest-dom'
|
2025-04-18 15:54:22 +08:00
|
|
|
import { cleanup } from '@testing-library/react'
|
|
|
|
|
|
2025-12-10 12:46:52 +08:00
|
|
|
// Fix for @headlessui/react compatibility with happy-dom
|
|
|
|
|
// headlessui tries to set focus property which is read-only in happy-dom
|
|
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
|
// Ensure window.focus is writable for headlessui
|
|
|
|
|
if (!Object.getOwnPropertyDescriptor(window, 'focus')?.writable) {
|
|
|
|
|
Object.defineProperty(window, 'focus', {
|
|
|
|
|
value: jest.fn(),
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-18 15:54:22 +08:00
|
|
|
afterEach(() => {
|
|
|
|
|
cleanup()
|
|
|
|
|
})
|