Files
xiaoxia-saas/apps/web/src/test/setup.ts
T
xiaoxia 8e924dc660
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 210h12m4s
CI/CD Pipeline / Frontend Lint (push) Failing after 210h14m3s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 210h14m7s
fix: correct _safe_parse_fps placement and format setup.ts (#133)
2026-06-30 18:40:02 +08:00

44 lines
1.1 KiB
TypeScript

/**
* 测试环境设置
*/
import { expect, afterEach } from "vitest";
import { cleanup } from "@testing-library/react";
import * as matchers from "@testing-library/jest-dom/matchers";
// Mock window.matchMedia for Ant Design components
Object.defineProperty(window, "matchMedia", {
writable: true,
value: (query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: () => {},
removeListener: () => {},
addEventListener: () => {},
removeEventListener: () => {},
dispatchEvent: () => false,
}),
});
// 扩展 Vitest 的 expect
expect.extend(matchers);
// 每次测试后清理
afterEach(() => {
cleanup();
});
// 全局类型声明
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Vi {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
interface Assertion<T = any> extends jest.Matchers<void, T> {}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
interface AsymmetricMatchersContaining extends jest.Matchers<void, any> {}
}
}
// 导出空对象以使文件成为模块
export {};