From fab481cd8f72307c53214d3544ae3474772c2e1a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 27 Mar 2026 13:05:24 +0000 Subject: [PATCH] Iterate jest utility --- apps/web/test/setupTests.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/web/test/setupTests.ts b/apps/web/test/setupTests.ts index 3137c25637..8f920b3910 100644 --- a/apps/web/test/setupTests.ts +++ b/apps/web/test/setupTests.ts @@ -68,10 +68,15 @@ require("./setup/setupLanguage"); require("./setup/setupConfig"); // Utility to check for React errors during the tests +// Fails tests on errors like the following: +// In HTML,
cannot be a descendant of

. +// In HTML,

cannot be a descendant of . +// In HTML, text nodes cannot be a child of . +// This will cause a hydration error. let errors: any[] = []; -const originalError = console.error; beforeEach(() => { errors = []; + const originalError = console.error; jest.spyOn(console, "error").mockImplementation((...args) => { if (/validateDOMNesting|Hydration failed|hydration error/i.test(args[0])) { errors.push(args[0]); @@ -80,6 +85,7 @@ beforeEach(() => { }); }); afterEach(() => { + mocked(console.error).mockRestore(); if (errors.length > 0) { throw new Error("Test failed due to React hydration errors in the console."); }