aboutsummaryrefslogtreecommitdiff
path: root/setupTests.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-10-30 12:37:09 +0300
committerGravatar Vitaly Takmazov2024-10-30 12:38:31 +0300
commit6118840a4af6b4e7120754555c01b8d41436625b (patch)
tree7f921a20a479e852e9d17ee6f6d957fbb08ac737 /setupTests.js
parent27cc7b006ac91be9dc883adaf7ea27c46d511df9 (diff)
Fix test environments
Diffstat (limited to 'setupTests.js')
-rw-r--r--setupTests.js22
1 files changed, 12 insertions, 10 deletions
diff --git a/setupTests.js b/setupTests.js
index 1b4e29f8..7658559c 100644
--- a/setupTests.js
+++ b/setupTests.js
@@ -1,14 +1,16 @@
import '@testing-library/jest-dom'
-window.matchMedia = window.matchMedia || function() {
- return {
- matches: true,
- media: '',
- addListener: function() { return true },
- removeListener: function() { return true },
- addEventListener: function() { return true },
- removeEventListener: function() { return true },
- dispatchEvent: function() { return true },
- onchange: function() { return true }
+if (typeof window !== 'undefined') {
+ window.matchMedia = window.matchMedia || function() {
+ return {
+ matches: true,
+ media: '',
+ addListener: function() { return true },
+ removeListener: function() { return true },
+ addEventListener: function() { return true },
+ removeEventListener: function() { return true },
+ dispatchEvent: function() { return true },
+ onchange: function() { return true }
+ }
}
}