Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test(core): fix useTheme observer-lifecycle test — mock MutationObserver as a constructable function (#3906)

Cindy Zhangcdee37b6784a
diff --git a/packages/core/src/theme/useTheme.test.tsx b/packages/core/src/theme/useTheme.test.tsx
index 5aa9fc892c..04acc56d50 100644
--- a/packages/core/src/theme/useTheme.test.tsx
+++ b/packages/core/src/theme/useTheme.test.tsx
@@ -229,9 +229,9 @@ describe('useTheme root-attribute observer lifecycle', () => {
it('shares one observer across multiple no-context consumers and disconnects once all unmount', () => {
const observe = vi.fn();
const disconnect = vi.fn();
- const ObserverSpy = vi
- .fn()
- .mockImplementation(() => ({observe, disconnect}));
+ const ObserverSpy = vi.fn().mockImplementation(function () {
+ return {observe, disconnect};
+ });
vi.stubGlobal('MutationObserver', ObserverSpy);
const first = renderHook(() => useTheme());