UNPKG

dnsweeper

Version:

Advanced CLI tool for DNS record risk analysis and cleanup. Features CSV import for Cloudflare/Route53, automated risk assessment, and parallel DNS validation.

70 lines (62 loc) 1.72 kB
import { expect, afterEach, vi } from 'vitest'; import { cleanup } from '@testing-library/react'; import * as matchers from '@testing-library/jest-dom/matchers'; // Testing Library のマッチャーを拡張 expect.extend(matchers); // 各テスト後にDOMをクリーンアップ afterEach(() => { cleanup(); }); // matchMedia をモック(Tailwind CSS のダークモード対応) 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(), })), }); // IntersectionObserver をモック global.IntersectionObserver = vi.fn().mockImplementation(() => ({ observe: vi.fn(), unobserve: vi.fn(), disconnect: vi.fn(), })); // ResizeObserver をモック global.ResizeObserver = vi.fn().mockImplementation(() => ({ observe: vi.fn(), unobserve: vi.fn(), disconnect: vi.fn(), })); // URLをモック(React Router用) Object.defineProperty(window, 'location', { value: { href: 'http://localhost:3000', origin: 'http://localhost:3000', pathname: '/', search: '', hash: '', }, writable: true, }); // localStorage をモック const localStorageMock = { getItem: vi.fn(), setItem: vi.fn(), removeItem: vi.fn(), clear: vi.fn(), }; vi.stubGlobal('localStorage', localStorageMock); // sessionStorage をモック const sessionStorageMock = { getItem: vi.fn(), setItem: vi.fn(), removeItem: vi.fn(), clear: vi.fn(), }; vi.stubGlobal('sessionStorage', sessionStorageMock);