test(repo): less noisy test output (#11505)

This commit is contained in:
David Luzar
2026-06-15 18:19:20 +02:00
committed by GitHub
parent 1cb9fff569
commit 28a9b1711d
3 changed files with 25 additions and 0 deletions
+16
View File
@@ -3,6 +3,7 @@ import fs from "fs";
// vitest.setup.ts
import "vitest-canvas-mock";
import "@testing-library/jest-dom";
import { configure } from "@testing-library/react";
import { vi } from "vitest";
import polyfill from "./packages/excalidraw/polyfill";
@@ -16,6 +17,21 @@ import {
Object.assign(globalThis, testPolyfills);
PolyfillLocalStorage();
// By default testing-library dumps the entire serialized DOM into the error
// message whenever a `waitFor`/`getBy*` fails, which floods the test output
// (often hundreds of lines of HTML per failure). Strip it out unless
// VITE_DEBUG_DOM is enabled (see .env.test), e.g. `VITE_DEBUG_DOM=true yarn test`.
const debugDom = ["true", "1"].includes(process.env.VITE_DEBUG_DOM ?? "");
if (!debugDom) {
configure({
getElementError: (message) => {
const error = new Error(message ?? undefined);
error.name = "TestingLibraryElementError";
return error;
},
});
}
vi.mock("@excalidraw/common", async (importOriginal) => {
const module = await importOriginal<typeof import("@excalidraw/common")>();