Skip to content

Commit

Permalink
Fix matchMedia compatibility to jest (#7431)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed May 16, 2024
1 parent 1e45450 commit 67057da
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/js/testSetup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,17 @@ jest.mock('sulu-admin-bundle/services/Config', () => ({
translations: ['en', 'de'],
fallbackLocale: 'en',
}));

Object.defineProperty(window, 'matchMedia', { // see https://github.com/ckeditor/ckeditor5/issues/16368
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(),
})),
});

0 comments on commit 67057da

Please sign in to comment.