From 0d3266ee466dfc6e4921ac6581b22c716c4307a9 Mon Sep 17 00:00:00 2001 From: "Mims H. Wright" Date: Thu, 24 Feb 2022 16:50:54 -0800 Subject: [PATCH] chore(tests): mocked the console object in tests Created a dummy console to supress warnings in the console when running tests re #204 --- jest.config.js | 1 + jest.config.vscode.js | 5 ++++- test/mockConsole.ts | 6 ++++++ test/{setup.ts => mockContext.ts} | 0 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/mockConsole.ts rename test/{setup.ts => mockContext.ts} (100%) diff --git a/jest.config.js b/jest.config.js index bfead08..507a178 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,4 +2,5 @@ module.exports = { preset: "ts-jest", runner: "@jest-runner/electron", testEnvironment: "@jest-runner/electron/environment", + setupFiles: ["/test/mockConsole.ts"], }; diff --git a/jest.config.vscode.js b/jest.config.vscode.js index 6490b3d..8cb7546 100644 --- a/jest.config.vscode.js +++ b/jest.config.vscode.js @@ -1,5 +1,8 @@ module.exports = { preset: "ts-jest", testEnvironment: "jsdom", - setupFiles: ["/test/setup.ts"], + setupFiles: [ + "/test/mockConsole.ts", + "/test/mockContext.ts", + ], }; diff --git a/test/mockConsole.ts b/test/mockConsole.ts new file mode 100644 index 0000000..286b66e --- /dev/null +++ b/test/mockConsole.ts @@ -0,0 +1,6 @@ +// eslint-disable-next-line @typescript-eslint/no-empty-function +const noop = () => {}; + +globalThis.console.log = noop; +globalThis.console.warn = noop; +globalThis.console.error = noop; diff --git a/test/setup.ts b/test/mockContext.ts similarity index 100% rename from test/setup.ts rename to test/mockContext.ts