-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Coverage report not working #7838
Comments
I'm hitting the same problem, for now the only workaround I found is to prepend So the working command is Obviously it has its own downsides. |
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. |
Not stale |
If I run it with the watchAll option to false it works
|
Any workarounds to have watch mode with coverage? |
Mmmm no idea. When I develop I really don't want the application being instrumented and reporting coverage all time so I'm only generating the report when need to check it |
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. |
STFU stale bot |
Hello, I have a similar problem, but this time in the generated HTML for the coverage instead. Here are the steps I've done in order to reproduce this:
When the installation was finished I ran once again the test command and in the terminal, the report had all the coverage reported correctly, but the HTML was just showing the percent sign and no actual numbers (see screenshot attached). Do you think that the issues are related? Not sure how to debug this. Thank you! |
The bug in HTML was fixed: jestjs/jest#9388 |
@adyz updating |
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. |
Please disable this bot, I implore you |
It doesn't fix issue for me |
Can confirm that, on a project manged by yarn, running |
I noticed that issue exists because some options have unexpected behavior. In my case I placed {root}/test/jest.config.js and despite on I pointed --coverage argument issue was fixed for me when I setup the following jest.config.js const path = require("path");
const rootDir = process.cwd();
module.exports = {
verbose: true,
rootDir,
coverageDirectory: "coverage",
collectCoverageFrom: ["lib/**/*.{js,jsx}"],
}; As you can notice without rootDir it doesn't work, because if not rootDir is pointed the rootDir is __dirname of jest.config.js (if I properly understood). One more weird thing when we have couple projects in jest.config.json:
As you can see, you must point rootDir to each project. Why is main-rooDir not shared between ones I don't know. The same thing with moduleNameMapper option. It's unexpected behavior. Summary:
As for me, the issue is resolved. But I spent 4 hours for deep in this one :( |
Hi, I am not sure what the following code does.. Try removing that from package.json file. and run following command if you are on windows.
|
Just throwing my 2 cents, downgrading to |
That didn't work for me. |
don't have |
@pragyaPS would you please share some screenshots of the error that you are getting. If you can share the package.json file that would help me to debug further. |
Only adding ts-jest in transform jest options fixed this issue for me: "jest": {
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/ts-jest"
} Downgrading didn't help. UPD: You should install ts-jest first. |
@p-mazhnik Changed "babel-jest" to "ts-jest" and got an error message but running |
While I too faced this issue with default configuration (react-scripts:4.0.0), the below script worked perfectly fine for me.
I don't see any reason why this issue should be kept open. |
@fraindz suggestion is really good - however I believe I'm facing issues with Because it works just fine when I do
|
Just in case it helps anyone moving jest config from If you ejected CRA, this means you have to configure jest from scratch. |
My 2c with react-scripts 5.0.0 and non-ejected CRA project: I also got an empty coverage report and to fix that I need to explicitly pass a path argument: |
Coverage does not work for us with simple |
I also tried |
I headbutted with this issue, and
|
In my case the fault was with the regex given to the collectCoverageFrom argument. This didn't work
Worked
Maybe we have to more specific? |
npm test -- --coverage --watchAll=false With Jest 29 works! |
for me it worked like this "scripts": { specify the folders here: - |
Describe the bug
The problem is that I can't get the coverage report for any project. I used a brand new cra project to test if something is wrong locally but I still have the same problem.
This is what I am supposed to see:
Taken from: https://create-react-app.dev/docs/running-tests/#coverage-reporting
And this is what I see instead:
Did you try recovering your dependencies?
I did.
yarn --version
1.19.1
Environment
Environment Info:
System:
OS: macOS 10.15
CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
Binaries:
Node: 12.12.0 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Browsers:
Chrome: 77.0.3865.120
Firefox: 69.0
Safari: 13.0.2
npmPackages:
react: ^16.10.2 => 16.10.2
react-dom: ^16.10.2 => 16.10.2
react-scripts: 3.2.0 => 3.2.0
npmGlobalPackages:
create-react-app: 0.3.0
Steps to reproduce
Expected behavior
I should see the coverage report including the App.js file.
Actual behavior
I see no file included in the report:
Reproducible demo
Just used the latest CRA version in an empty project.
The text was updated successfully, but these errors were encountered: