-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running in headless tests produces "Error: matchMedia not present" #82
Comments
I guess the problem is that Zombie omits the matchMedia API. Reading through the docs it seems that this is the case. What are you trying to test: Your code using enquire? Or something else, where enquire is incidental? If the latter you could easily stub out the matchMedia API: window.matchMedia = window.matchMedia || function() {
return {
matches : false,
addListener : function() {},
removeListener: function() {}
};
}; If the former, then you have to do a proper polyfill. Presumably this is possible with zombie (since it explicitly omits a lot of APIs, I assume there must be some way to do it)? |
Thx man. Stubbing out that API is a good idea. With this my Zombie tests won't crash anymore. |
Hi, I know that this is closed but I can't get it to work. I've tried stubbing matchMedia both inside the test file and in a separate file link in under jest in package.json. The result is always that matchMedia is undefined in enquire.js What am I missing? |
Hi again
When I run my app with enquire.js in an automated headless test unit like https://github.com/assaf/zombie then following error is produced and is polluting my console:
Not sure what a solution would be. Probably a new option would be good.
The text was updated successfully, but these errors were encountered: