window.matchMedia is not a function code example
Example: window.matchMedia is not a function
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});
import './matchMedia.mock';
import {myMethod} from './file-to-test';
describe('should test this methhod that use matchmedia', () => {
});