mirror of
https://github.com/luxdao/stack.git
synced 2026-10-30 18:13:59 +00:00
33 lines
824 B
TypeScript
33 lines
824 B
TypeScript
import '@testing-library/jest-dom';
|
|
import { expect, afterEach, vi } from 'vitest';
|
|
import { cleanup } from '@testing-library/react';
|
|
|
|
// Extend Vitest's expect with jest-dom matchers
|
|
// expect.extend(matchers);
|
|
|
|
// Cleanup after each test
|
|
afterEach(() => {
|
|
cleanup();
|
|
});
|
|
|
|
// Mock window.matchMedia
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: vi.fn().mockImplementation(query => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(), // deprecated
|
|
removeListener: vi.fn(), // deprecated
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
})),
|
|
});
|
|
|
|
// Mock IntersectionObserver
|
|
global.IntersectionObserver = vi.fn().mockImplementation(() => ({
|
|
observe: vi.fn(),
|
|
unobserve: vi.fn(),
|
|
disconnect: vi.fn(),
|
|
})); |