Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does code coverage get bundled into production builds? #8

Closed
coltonehrman opened this issue Oct 4, 2023 · 5 comments
Closed

Does code coverage get bundled into production builds? #8

coltonehrman opened this issue Oct 4, 2023 · 5 comments

Comments

@coltonehrman
Copy link

Will the istanbul code coverage instrumented code get bundled for production and be part of a production build?

@kylemh
Copy link
Owner

kylemh commented Oct 4, 2023

It will show up in the server bundle since it's require()'d inside pages/api; however, there's no client entry point for any of the test code so it won't show up in the client-side bundle.

You can test this yourself with https://github.com/vercel/next.js/tree/canary/packages/next-bundle-analyzer

@kylemh kylemh closed this as completed Oct 4, 2023
@coltonehrman
Copy link
Author

It will show up in the server bundle since it's require()'d inside pages/api; however, there's no client entry point for any of the test code so it won't show up in the client-side bundle.

Does that mean that the production code getting deployed would be instrumented with code coverage lines? That would be a performance hit and not ideal.

@kylemh
Copy link
Owner

kylemh commented Oct 5, 2023

It would show up in the server bundle overall; however, I believe API routes are code-split by default with Next.js so only this specific route would include the dependency. Additionally, the instrumentation is for the UI code only. So, I don't see that it's possible for instrumentation code to be included anywhere in your actual application code.

@coltonehrman
Copy link
Author

It would show up in the server bundle overall; however, I believe API routes are code-split by default with Next.js so only this specific route would include the dependency. Additionally, the instrumentation is for the UI code only. So, I don't see that it's possible for instrumentation code to be included anywhere in your actual application code.

Ah, so this does not instrument server-side code? So this won't allow me to collect coverage on the server?

@kylemh
Copy link
Owner

kylemh commented Oct 5, 2023

Correct. That's an open issue here: #3

If you find a solution, definitely let me know! It seems to be a limitation of @cypress/code-coverage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants