yocontra/react-responsive

How to write test case for <MediaQuery minDeviceWidth={1024}> ?

kajalj3098 opened this issue · 3 comments

image
this doesnt works for me

You probably need to set deviceWidth not width in the ResponsiveContext.Provider value prop

I've just lost like 3 hours because this is not well documented. Could you please review the documentation around testing in the Readme?

I'm guessing this is not the first time someone gets stuck (and tries mocking matchMedia in their test env). Thanks in advance!

@arturmiglio If there are improvements you'd like to see in the documentation please feel free to make a PR to add more information. I try as best as I can to make the docs informative but it is a large surface area and hard to document every single possible way it could be used. FWIW the deviceWidth property is in the README right in the section describing how to emulate a device for testing: https://github.com/yocontra/react-responsive#forcing-a-device-with-the-device-prop=