mirror of
https://github.com/vercel/ai-elements.git
synced 2026-09-14 19:48:26 +08:00
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import "@testing-library/jest-dom/vitest";
|
|
import { cleanup } from "@testing-library/react";
|
|
import failOnConsole from "vitest-fail-on-console";
|
|
|
|
// Mock clipboard API for browser environment
|
|
// oxlint-disable-next-line eslint-plugin-jest(require-hook)
|
|
Object.defineProperty(navigator, "clipboard", {
|
|
configurable: true,
|
|
value: {
|
|
// oxlint-disable-next-line eslint-plugin-promise(prefer-await-to-then)
|
|
writeText: vi.fn(() => Promise.resolve()),
|
|
},
|
|
writable: true,
|
|
});
|
|
|
|
// Fail the test if there are any console logs during test execution
|
|
// oxlint-disable-next-line eslint-plugin-jest(require-hook)
|
|
failOnConsole({
|
|
shouldFailOnAssert: true,
|
|
shouldFailOnDebug: true,
|
|
shouldFailOnError: true,
|
|
shouldFailOnInfo: true,
|
|
shouldFailOnLog: true,
|
|
shouldFailOnWarn: true,
|
|
silenceMessage: (message) => {
|
|
// Silence React 18 deprecation warnings from Radix UI dependencies
|
|
if (message.includes("ReactDOM.render is deprecated since React 18")) {
|
|
return true;
|
|
}
|
|
// Silence Sonner deprecation warnings
|
|
if (message.includes("toastOptions.className")) {
|
|
return true;
|
|
}
|
|
// Silence React act() warnings from Radix UI tooltip timing
|
|
if (message.includes("was not wrapped in act")) {
|
|
return true;
|
|
}
|
|
// Silence Radix UI DialogContent accessibility warnings in tests
|
|
// Tests use aria-describedby="test-description" but don't render the element
|
|
if (message.includes("Missing `Description` or `aria-describedby")) {
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
});
|
|
|
|
// Cleanup after each test - this is a global setup file
|
|
// oxlint-disable-next-line eslint-plugin-jest(no-hooks), eslint-plugin-jest(require-top-level-describe)
|
|
afterEach(() => {
|
|
cleanup();
|
|
vi.restoreAllMocks();
|
|
});
|