test(repo): less noisy test output (#11505)
This commit is contained in:
@@ -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")>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user