How to mock out sub-components when unit testing a React component with Jest How to mock out sub-components when unit testing a React component with Jest reactjs reactjs

How to mock out sub-components when unit testing a React component with Jest


If you would require your SASS and LESS and CSS files in the main component instead of in each sub component you would not get this problem as you test the components on their own.

There are some other solutions mentioned in this issue report if you don't like the one I provided. Issue 334