diff --git a/jest.config.json b/jest.config.json index de350cd4..b9c1aec0 100644 --- a/jest.config.json +++ b/jest.config.json @@ -24,5 +24,5 @@ "^@mui/material$": "/node_modules/@mui/material" }, "transformIgnorePatterns": ["node_modules/(?!(axios)/)", "/node_modules/"], - "setupFiles": ["fake-indexeddb/auto"] + "setupFiles": ["fake-indexeddb/auto", "/src/setup.ts"] } diff --git a/src/setup.ts b/src/setup.ts new file mode 100644 index 00000000..5e5a14d6 --- /dev/null +++ b/src/setup.ts @@ -0,0 +1,13 @@ +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(), + })), +}); diff --git a/tsconfig.json b/tsconfig.json index 0fba4cbe..a08c8b20 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,5 +21,5 @@ "baseUrl": "src" }, "allowImportingTsExtensions": true, - "include": ["src"] + "include": ["src", "src/setup.ts"] }