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

ENOENT: No such file coverage-summary.json #17

Open
webpolis opened this issue May 6, 2020 · 12 comments
Open

ENOENT: No such file coverage-summary.json #17

webpolis opened this issue May 6, 2020 · 12 comments

Comments

@webpolis
Copy link

webpolis commented May 6, 2020

Hi

I set it up exactly as explained in master's README but it fails with below error. Using Jest v26.0.1:

Error: ENOENT: no such file or directory, open './coverage/coverage-summary.json'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:badges: `npm run test:coverage && jest-coverage-badges`
npm ERR! Exit status 1

Thanks

@babacarcissedia
Copy link

I tried running npm run test:coverage && jest-coverage-badges --input ./coverage/coverage-final.json
but got

Snapshots:   0 total
Time:        9.934s, estimated 14s
Ran all test suites.
/home/bcdbuddy/myfol/workspaces/github/node-paps/node_modules/jest-coverage-badges/cli.js:53
    throw new Error('malformed coverage report');
    ^

Error: malformed coverage report
    at getBadge (/home/bcdbuddy/myfol/workspaces/github/node-paps/node_modules/jest-coverage-badges/cli.js:53:11)
    at /home/bcdbuddy/myfol/workspaces/github/node-paps/node_modules/jest-coverage-badges/cli.js:81:15
    at Array.forEach (<anonymous>)
    at /home/bcdbuddy/myfol/workspaces/github/node-paps/node_modules/jest-coverage-badges/cli.js:103:14
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:61:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

So it seems like a version problem

@vinayakshenoy91
Copy link

Hi

I set it up exactly as explained in master's README but it fails with below error. Using Jest v26.0.1:

Error: ENOENT: no such file or directory, open './coverage/coverage-summary.json'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:badges: `npm run test:coverage && jest-coverage-badges`
npm ERR! Exit status 1

Thanks

There are couple of things to be added: Make sue you have the jest command added under your package json script:

  "test": "jest",
   "test:coverage": "npm test -- --coverage",
   "test:badges": "npm run test:coverage  && jest-coverage-badges 

Also make sure you have all the jest output files going into coverage folder. For that you need to added the below config in jest.config.js:
coverageDirectory: "coverage"

@webpolis
Copy link
Author

webpolis commented May 18, 2020

Thanks.

But is the same. It keeps returning the same error. Now, in a new blank project.

My jest.config:

module.exports = {
  preset: "ts-jest",
  testEnvironment: "jsdom",
  transform: {
    ".(ts|tsx)": "ts-jest",
  },
  moduleFileExtensions: ["ts", "tsx", "js", "json"],
  coverageDirectory: "coverage",
};

My package.json scripts:

    "test:badges": "npm run test:coverage  && jest-coverage-badges",
    "test:coverage": "npm test -- --coverage",

Coverage runs great, it just fail when I use this tool.

Results:

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |     100 |        0 |     100 |     100 |                   
 index.ts |     100 |        0 |     100 |     100 | 54-90             
----------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests:       10 passed, 10 total
Snapshots:   0 total
Time:        2.337 s
Ran all test suites matching /src\//i.
/home/nico/dev/projects/percyst/node_modules/jest-coverage-badges/cli.js:99
    throw err;
    ^

Error: ENOENT: no such file or directory, open './coverage/coverage-summary.json'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:badges: `npm run test:coverage  && jest-coverage-badges`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test:badges script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/nico/.npm/_logs/2020-05-18T23_48_17_778Z-debug.log

Regards

@gabrielsiedler
Copy link

Make sure you have json-summary in the coverageReporters configuration:

"jest": {
  "coverageReporters": [
    "json-summary", 
    "text",
    "lcov"
  ]
}

this reporter is responsible for generating the coverage-summary.json file

@webpolis
Copy link
Author

Thanks, but that's also there. As someone mentioned here, it's a version issue. Currently, this package is outdated in relation with its dependencies.

@hollandjake
Copy link

hollandjake commented Oct 22, 2020

I had this issue. FIX was to ensure you dont have a jest.config.js file this will be override the package.json. Optionally you can add the configs into the jest.config.js

[Running on jest 26.6.0]

@elgsantos
Copy link

I had this issue on windows, for me the solution was to remove the quotes from input and output:
jest --coverage && jest-coverage-badges --input coverage/coverage-summary.json --output __badges__

( "jest": "^26.6.3", "jest-coverage-badges": "^1.1.2")

@ghost
Copy link

ghost commented Feb 27, 2021

For those who are still experiencing this issue, if you got a specific jest.config.js in your project, make sure to set the json value in coverageReporters option exactly as indicated by @gabrielsiedler on his example, so:

coverageReporters: [
    "json-summary", <- Not "json" but "json-summary": this is important!
    "text",
    "lcov",
    "clover"
  ]

@RicardoGomesRocha
Copy link

@hollandjake and @elgsantos (here and here).

So, @pamepeixinho I think this issue can be closed.

@ciriousjoker
Copy link

ciriousjoker commented Mar 5, 2022

Can be closed imo.

Basically, copy coverageReporter from package.json into jest.config.js:

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
  preset: "ts-jest",
  testEnvironment: "node",
  // here:
  coverageReporters: ["json-summary", "text", "lcov"],
};

@jrichardsz
Copy link

jrichardsz commented Dec 11, 2022

Make sure you have json-summary in the coverageReporters configuration:

"jest": {
  "coverageReporters": [
    "json-summary", 
    "text",
    "lcov"
  ]
}

this reporter is responsible for generating the coverage-summary.json file

Worked for me, thanks!!

"jest": "^27.3.1",
"jest-badge-generator": "^1.1.5"

@francoatmega
Copy link

francoatmega commented Oct 31, 2023

For me worked when I add some files an directories to ingore, remember to check this too.
Worked when I fixed the paths to ignore like this:

coveragePathIgnorePatterns: ['/node_modules/', 'src/infra/db/*']

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

10 participants