-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Code coverage comments like /* istanbul ignore file */
are ignored for jsx files
#6106
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
Comments
Hi @dbartholomae, you can actually use Jest here to ignore files. I know Istanbul comments work with Jest, but I'm not sure that specific comment does. As an example, here I'm ignoring all
|
Thanks! Unfortunately that solution isn't ideal as I will have to add it to multiple files, and adding it in a central file introduces unnecessary coupling that makes it harder to refactor later on. |
Hi @dbartholomae, I understand - I had assumed this was a jest issue, and that would explain why they have the coverage ignore patterns. So, it sounds like the JSX transform is removing the comments... but that's also quite confusing, as it would be affecting a lot of people. Can you see the comments in your HTML report? |
Yes, the comments are shown. I've also set up a repo which reproduces the bug with basically 2 lines changed compared to the vanilla verion created by create-react-app: |
In my case, the file I add the comment to drops to |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
@mrmckeb may you guys add some label to prevent this from getting auto-closed by the stale bot? This is a verified issue, there's no reason to close it automatically just because you guys are busy working on other things. |
Hi @FezVrasta, sorry about that. We need to investigate this more. Would anyone be interested in picking this up and submitting a PR? If not, I can take a look this week. |
+1 |
I'm trying to upgrade to 3.x one of my projects and now I'm reproducing this issue even on Thanks! |
FWIW, for me the file was was only ignored if I placed this comment at the top of the file and had a newline between it and the next block: WORKS
DOES NOT WORK
|
I don't seem to have this issue on |
What @jensbodal said is true also for .ts files. However I'm experience some confusing results my code This works
but this doesn't work (swapping imports order)
Adding a newline results in both working. |
* Babel for ESLint import assertion: * https://stackoverflow.com/a/73225592 * https://stackoverflow.com/a/72167806 * DISABLE instanbul for inspecting JSON imports * facebook/create-react-app#6106 (comment)
* Babel for ESLint import assertion: * https://stackoverflow.com/a/73225592 * https://stackoverflow.com/a/72167806 * DISABLE instanbul for inspecting JSON imports * facebook/create-react-app#6106 (comment)
When using |
same issue
|
Any istanbul ignore works when using `coverageProvider: "v8"...
|
If I use coverageProvider: “v8” then the whole file becomes covered, even if there is only one test. |
If you're using it with
|
/* istanbul ignore file @preserve */Carlos Benavides |
Is this a bug report?
Yes
Did you try recovering your dependencies?
Yes - I have a minimum repo to reproduce.
Which terms did you search for in User Guide?
istanbul comment
coverage comment
Environment
System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Binaries:
Yarn: 1.12.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 42.17134.1.0
Internet Explorer: 11.0.17134.1
npmPackages:
react: ^16.7.0 => 16.7.0
react-dom: ^16.7.0 => 16.7.0
react-scripts: 2.1.2 => 2.1.2
npmGlobalPackages:
create-react-app: Not Found
Steps to Reproduce
Code coverage comments like
/* istanbul ignore file */
are ignored for jsx files. When you set up a new app, adding this line toindex.js
doesn't work. This seems to be related to the Babel config as pure JS files work fine.Here's an example repo:
npm test
(note that the command is modified in package.json and includes the coverage flag)This could be related to #5756
Expected Behavior
Neither
index.js
norindex-no-jsx.js
should show up in the coverage-report.Actual Behavior
index.js
shows up in the coverage-report.Reproducible Demo
See "Steps to Reproduce"
The text was updated successfully, but these errors were encountered: