1
votes

I have a React application and I added tests with jest and enzyme. I make a unit test for a react component called <Duration.jsx />. And the coverage shows me all components coverage inside <Duration.jsx /> and files.scss. Is it normal?

1
if you are asking how to skip analyzing SASS files for test coverage there is dedicated config option for that: collectCoverageFrom - skyboyer

1 Answers

0
votes

I think this depends on how you write your tests. IMHO, the coverage is a by-product of tests. For example, if you use enzyme and shallow(<LayoutMessage />), then you are not going to render the children of LayoutMessage.

If you render normally using render(<LayoutMessage />) then you will also render the children of LayoutMessage, increasing the lines that your tests execute.

Here's a sample picture for testing individual component. enter image description here