setup.ts 882 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import '@testing-library/jest-dom';
  2. import { vi } from 'vitest';
  3. // Mock window.matchMedia
  4. Object.defineProperty(window, 'matchMedia', {
  5. writable: true,
  6. value: vi.fn().mockImplementation((query: string) => ({
  7. matches: false,
  8. media: query,
  9. onchange: null,
  10. addListener: vi.fn(), // deprecated
  11. removeListener: vi.fn(), // deprecated
  12. addEventListener: vi.fn(),
  13. removeEventListener: vi.fn(),
  14. dispatchEvent: vi.fn(),
  15. })),
  16. });
  17. // Mock ResizeObserver
  18. global.ResizeObserver = vi.fn().mockImplementation(() => ({
  19. observe: vi.fn(),
  20. unobserve: vi.fn(),
  21. disconnect: vi.fn(),
  22. }));
  23. // Mock IntersectionObserver
  24. global.IntersectionObserver = vi.fn().mockImplementation(() => ({
  25. observe: vi.fn(),
  26. unobserve: vi.fn(),
  27. disconnect: vi.fn(),
  28. }));
  29. // Mock URL.createObjectURL
  30. URL.createObjectURL = vi.fn();
  31. // Mock window.open
  32. window.open = vi.fn();