Return statement on response resolver is not covered according to Jest #942
-
I am new to using jest and msw. In a testing utils file, I'm mocking a server and exporting it (I am using this in a React/Redux project with TypeScript). Currently, Jest is covering this file.
When I run all tests, Jest's coverage report tells me that the return statement on my responseResolver function is an uncovered line. Why is that, and how can I fix it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Upon re-running my test scripts, I find that the coverage report shows no uncovered lines. I cannot re-duplicate this issue right now, so I am marking this question as answered - although any insights are still appreciated. My apologies! |
Beta Was this translation helpful? Give feedback.
-
Hey, @krallj. The logic you write with MSW is often meant to help during testing. Although you can test it, there's little practical benefit to doing that. If the mocking logic is incorrect, the test should fail. If it doesn't, there are even bigger issues going on. Exclude the MSW setup from test coverage, unless you wish to write tests for your setup (which you should have a really strong reason to do). MSW itself is rather well tested, so if you ever decide on introducing extra tests, they'd be scoped to your own logic that you put into MSW. Your own tests are the reflection of that logic's intentions. Rely on your tests. |
Beta Was this translation helpful? Give feedback.
Hey, @krallj.
The logic you write with MSW is often meant to help during testing. Although you can test it, there's little practical benefit to doing that. If the mocking logic is incorrect, the test should fail. If it doesn't, there are even bigger issues going on.
Exclude the MSW setup from test coverage, unless you wish to write tests for your setup (which you should have a really strong reason to do). MSW itself is rather well tested, so if you ever decide on introducing extra tests, they'd be scoped to your own logic that you put into MSW. Your own tests are the reflection of that logic's intentions. Rely on your tests.