My error is matchMedia not present, legacy browsers require a polyfill
I am running my tests with jest.
It's specifically happening in the react-responsive-mixin
What is the browser that you are targeting?
Jest ships with jsdom.

Just a snippet from the jest jQuery tutorial at https://facebook.github.io/jest/docs/tutorial-jquery.html
I am sorry. But what exactly is the issue here? You are not able to test the slick component in jest, is that correct?
Correct. These are the settings for the component.
var settings = {
autoplay: true,
dots: false,
infinite: true,
speed: 500,
rtl: false,
pauseOnHover: true,/*not working*/
responsive: [
{
breakpoint: 479,
settings: {
slidesToScroll: 1,
slidesToShow: 1
}
},
{
breakpoint: 767,
settings: {
slidesToScroll: 1,
slidesToShow: 1
}
},
{
breakpoint: 991,
settings: {
slidesToScroll: 1,
slidesToShow: 6
}
},
{
breakpoint: 1200,
settings: {
slidesToScroll: 1,
slidesToShow: 6
}
},
{
breakpoint: 2840,
settings: {
slidesToScroll: 1,
slidesToShow: 6
}
}
]
The issue is that enquire js not seeing matchMedia, which is under the react-responsive-mixin.
Full error is
Error: /Users/thomas/Sites/design-2-1/server/isomorphic/components/TrendingSlider.js: /Users/thomas/Sites/design-2-1/node_modules/react-slick/lib/index.js: /Users/thomas/Sites/design-2-1/node_modules/react-slick/lib/slider.js: /Users/thomas/Sites/design-2-1/node_modules/react-slick/node_modules/react-responsive-mixin/index.js: /Users/thomas/Sites/design-2-1/node_modules/react-slick/node_modules/react-responsive-mixin/node_modules/enquire.js/dist/enquire.js: matchMedia not present, legacy browsers require a polyfill
I found that stubbing it out was the solution because the browser is headless.
This is where I found the answer. Thanks.
@trodrigu please where does the stub go? Testcase or component?
@fadeojo you should add below jest config in package.json and add test-setup.js file
https://github.com/akiran/react-slick/blob/master/package.json#L74-L76
https://github.com/akiran/react-slick/blob/master/test-setup.js
@akiran Thanks, I got it working.
@akiran Running into the same problem while building to static bundle using "react-static-webpack-plugin". What can be done? While in dev everything works fine.
I have the same problem with react-static-webpack-plugin, @yyynnn did you find a solution?
I'm having the same problem @yyynnn how did you resolve this? WOuld love to hear from you @akiran on what to do when building :)
Thanks!
Most helpful comment
@fadeojo you should add below jest config in package.json and add test-setup.js file
https://github.com/akiran/react-slick/blob/master/package.json#L74-L76
https://github.com/akiran/react-slick/blob/master/test-setup.js