vitest-matchmedia-mock
v1.0.6
Published
mocking window.matchmedia with vitest
Downloads
18,969
Readme
Vitest MatchMediaMock
how to import:
import MatchMediaMock from 'vitest-matchmedia-mock`
Usage example
describe('your test', () => {
let matchMediaMock = new MatchMediaMock();
afterAll(() => {
matchMediaMock.clear();
});
});
Use Media Query
describe('your test', () => {
let matchMediaMock = new MatchMediaMock();
beforeAll(() => {
matchMediaMock.useMediaQuery('(prefers-color-scheme: dark)');
});
afterEach(() => {
matchMediaMock.clear();
});
afterAll(() => {
matchMediaMock.destroy();
});
});