setupTests.ts 582 B

1234567891011121314151617181920212223
  1. // vitest.setup.ts
  2. import "vitest-canvas-mock";
  3. import "@testing-library/jest-dom";
  4. import { vi } from "vitest";
  5. import polyfill from "./polyfill";
  6. import { testPolyfills } from "./tests/helpers/polyfills";
  7. Object.assign(globalThis, testPolyfills);
  8. require("fake-indexeddb/auto");
  9. polyfill();
  10. vi.mock("nanoid", () => {
  11. return {
  12. nanoid: vi.fn(() => "test-id"),
  13. };
  14. });
  15. // ReactDOM is located inside index.tsx file
  16. // as a result, we need a place for it to render into
  17. const element = document.createElement("div");
  18. element.id = "root";
  19. document.body.appendChild(element);