From 370424af2d1437da3d374ff5bdfe87c81d82522b Mon Sep 17 00:00:00 2001 From: Michael Taylor <162068037+mctylr-gh@users.noreply.github.com> Date: Sun, 5 Oct 2025 16:31:15 -0300 Subject: [PATCH] JEST: Quiet Jest tests output on expected failures (#2332) --- test/jest/Netscript/UserInterface.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/jest/Netscript/UserInterface.test.ts b/test/jest/Netscript/UserInterface.test.ts index f0a483167..858b2021c 100644 --- a/test/jest/Netscript/UserInterface.test.ts +++ b/test/jest/Netscript/UserInterface.test.ts @@ -57,12 +57,17 @@ describe("setTheme", () => { }); describe("Failure", () => { + let spyConErr: jest.Spied; + beforeEach(() => { + spyConErr = jest.spyOn(console, "error").mockImplementation(() => null); + }); test("Full theme", () => { const ns = getNS(); const newTheme = ns.ui.getTheme(); newTheme.primary = ""; ns.ui.setTheme(newTheme); const result = ns.ui.getTheme(); + expect(spyConErr).toHaveBeenCalled(); expect(result.primary).toStrictEqual(defaultTheme.primary); }); test("Partial theme", () => { @@ -72,8 +77,12 @@ describe("setTheme", () => { }; ns.ui.setTheme(newTheme as unknown as UserInterfaceTheme); const result = ns.ui.getTheme(); + expect(spyConErr).toHaveBeenCalled(); expect(result.primary).toStrictEqual(defaultTheme.primary); }); + afterEach(() => { + spyConErr.mockRestore(); + }); }); }); @@ -123,12 +132,17 @@ describe("setStyles", () => { }); describe("Failure", () => { + let spyConErr: jest.Spied; + beforeEach(() => { + spyConErr = jest.spyOn(console, "error").mockImplementation(() => null); + }); test("Full styles", () => { const ns = getNS(); const newStyles = ns.ui.getStyles(); (newStyles.fontFamily as unknown) = 123; ns.ui.setStyles(newStyles); const result = ns.ui.getStyles(); + expect(spyConErr).toHaveBeenCalled(); expect(result.fontFamily).toStrictEqual(defaultStyles.fontFamily); }); test("Partial styles", () => { @@ -138,7 +152,11 @@ describe("setStyles", () => { }; ns.ui.setStyles(newStyles as unknown as IStyleSettings); const result = ns.ui.getStyles(); + expect(spyConErr).toHaveBeenCalled(); expect(result.fontFamily).toStrictEqual(defaultStyles.fontFamily); }); + afterEach(() => { + spyConErr.mockRestore(); + }); }); });