@shopgate/pwa-unit-test 7.32.0-beta.6 → 7.32.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/testSetup.js +19 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-unit-test",
3
- "version": "7.32.0-beta.6",
3
+ "version": "7.32.0-beta.8",
4
4
  "description": "The unit tests setup for Shopgate's ENGAGE.",
5
5
  "author": "Shopgate <support@shopgate.com>",
6
6
  "license": "Apache-2.0",
package/testSetup.js CHANGED
@@ -38,3 +38,22 @@ jest.mock('@shopgate/pwa-common/collections/media-providers/style', () => ({
38
38
 
39
39
  // Mock the useTheme hook to prevent failing tests due to missing theme object
40
40
  jest.mock('@shopgate/engage/styles/theme/hooks/useTheme');
41
+
42
+ // jsdom doesn't implement matchMedia. Components that check media queries - the `useReduceMotion`
43
+ // hook behind every v2 button, breakpoint providers - would throw in every spec that renders them.
44
+ // Specs that care about the result can still override this with their own stub.
45
+ if (!window.matchMedia) {
46
+ Object.defineProperty(window, 'matchMedia', {
47
+ writable: true,
48
+ value: query => ({
49
+ matches: false,
50
+ media: query,
51
+ onchange: null,
52
+ addListener: jest.fn(),
53
+ removeListener: jest.fn(),
54
+ addEventListener: jest.fn(),
55
+ removeEventListener: jest.fn(),
56
+ dispatchEvent: jest.fn(),
57
+ }),
58
+ });
59
+ }