-
Notifications
You must be signed in to change notification settings - Fork 47
Next.js - API handlers not covered in coverage report #27
Comments
Got any ideas for a workaround? |
As far as I know, these API handlers are executed on the server side of Next.js. The coverage example in this repository does only collect the frontend coverage via the istanbul plugin. But unsure, I'm not using Next.js that often. |
I was thinking that the transpilation of the api fns would've gone through babel and hence istanbul as well, but maybe they have another transpilation model on the server. |
If I'm not wrong, Next.js in fact use their own Babel plugin to separate browser-side code and server-side code from one JS file. I guess their Babel plugin is just not compatible with istanbul plugin. Since the server-side code is running on the NodeJS environment, maybe you can test it with separate jest test cases and use jest to collect the coverage information. |
Yeah, it's of course possible to spin up the API and do integration tests against it, but it'd be better if I could just combine it into the same test suite. I avoid unit tests as far as possible, having e2e tests collect coverage % would be a real eureka moment, then I could just focus on writing tests that are representing real-user behavior and use the cov to see weak spots in my tests / make unit/integration tests for extra hairy bits. |
See/try PR #26 for more details
The text was updated successfully, but these errors were encountered: