From 9c8994c37aae6118eb14d2e1b911beaa471d0847 Mon Sep 17 00:00:00 2001 From: Valery Melou Date: Sun, 21 Jul 2024 05:05:14 +0100 Subject: [PATCH] tests: fix failing tests --- libs/shared/layout/src/test-setup.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/libs/shared/layout/src/test-setup.ts b/libs/shared/layout/src/test-setup.ts index 156b8f2..d8a8be4 100644 --- a/libs/shared/layout/src/test-setup.ts +++ b/libs/shared/layout/src/test-setup.ts @@ -1,8 +1,22 @@ // @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment globalThis.ngJest = { -testEnvironmentOptions: { - errorOnUnknownElements: true, - errorOnUnknownProperties: true, -}, + testEnvironmentOptions: { + errorOnUnknownElements: true, + errorOnUnknownProperties: true, + }, }; import 'jest-preset-angular/setup-jest'; + +Object.defineProperty(window, 'matchMedia', { + writable: true, + value: jest.fn().mockImplementation((query) => ({ + matches: false, + media: query, + onchange: null, + addListener: jest.fn(), // Deprecated + removeListener: jest.fn(), // Deprecated + addEventListener: jest.fn(), + removeEventListener: jest.fn(), + dispatchEvent: jest.fn(), + })), +});