-
Notifications
You must be signed in to change notification settings - Fork 260
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
Jest --coverage : help #126
Comments
Just add: "test": "node --harmony_proxies node_modules/.bin/jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", |
Thanks @jseminck would be good to add this to the README, I think? |
I followed @jseminck approach, but now Im getting the following error:
Any ideas? Thanks in advanced. |
@ndelvalle, most likely, your |
yep @cdaringe that was the problem 👍 |
👍 |
Thanks, guys. |
jest works with globals so they have to be added to the Eslint configuration. I decided to move tests next to the files they test (jest picks up files that are name *.test.js) to make them easier to locate. They need to be ignored by babel to not show up in the lib folder (that is published to npm). jest comes with a coverage tool and a watch mode so nyc and npm-watch are no longer needed. nickmerwin/node-coveralls#126 (comment)
jest works with globals so they have to be added to the Eslint configuration. I decided to move tests next to the files they test (jest picks up files that are name *.test.js) to make them easier to locate. They need to be ignored when the code is published to npm (instead of the test folder). jest comes with a coverage tool and a watch mode so nyc and npm-watch are no longer needed. nickmerwin/node-coveralls#126 (comment)
jest works with globals so they have to be added to the Eslint configuration. I decided to move tests next to the files they test (jest picks up files that are name *.test.js) to make them easier to locate. The .test.js files need to be ignored when the application is build (they are not needed to run and are shown as extra testcases otherwise). https://github.com/skovhus/jest-codemods/blob/master/package.json (scripts section) jest comes with a coverage tool and a watch mode so nyc and npm-watch are no longer needed. nickmerwin/node-coveralls#126 (comment) The jest configuration ensures that all src files are checked when the coverage report is created (even when they are never required) and makes sure that the compiled code is ignored.
jest works with globals so they have to be added to the Eslint configuration. I decided to move tests next to the files they test (jest picks up files that are name *.test.js) to make them easier to locate. The .test.js files need to be ignored when the application is build (they are not needed to run and are shown as extra testcases otherwise). https://github.com/skovhus/jest-codemods/blob/master/package.json (scripts section) jest comes with a coverage tool and a watch mode so nyc and npm-watch are no longer needed. nickmerwin/node-coveralls#126 (comment) The jest configuration ensures that all src files are checked when the coverage report is created (even when they are never required) and makes sure that the compiled code is ignored. babel-jest is needed to transform the code (including tests) before it is executed. It just needs to be installed (will be used automatically). ES6 modules do not work without it.
Can this be added to the README? |
👍 For adding to readme. Is there any advantage to any specific coverage format? Which file in
|
Why not use a script like this?
|
Personally I like to set |
😮 now I got it, so most people don't have I was asking about that part specially. By the way I think this is the best approach to maintain configurations clearer. As a side effect you had clarify my doubt 😆, thanks man |
I don't think that's the case. Assuming that the other technique is to |
@nickmccurdy Your solution isnot supported by create-react-app |
Yes, but you can still use |
Yeah, |
This is how I got it to work
|
@jseminck, @tizmagik: sorry to bother in this thread. I'm using jest + enzyme, and hoping to pipe the coverage results to coveralls. So, I implemented "scripts": {
"build:browserify": "browserify -t [ babelify --presets env,stage-2,react ] content.jsx > ../../interface/static/js/content.js",
"prebuild:dos2unix": "find . -type f -print0 | xargs -0 dos2unix",
"watch:jsx": "onchange 'src/jsx/**/*.jsx' 'src/jsx/**/*.js' -- npm run build:browserify",
"test": "NODE_ENV=test jest --config jest.config.js",
"test:coveralls": "npm run test --coverage --coverageReporters=lcov.info | ./node_modules/coveralls/bin/coveralls.js"
}, I've verified both [error] "2018-05-31T16:37:12.946Z" 'error from convertLcovToCoveralls'
/home/travis/build/jeff1evesque/machine-learning/src/jsx/node_modules/coveralls/bin/coveralls.js:18
throw err;
^
Failed to parse string
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:coveralls: `npm run test --coverage --coverageReporters=lcov.info | ./node_modules/coveralls/bin/coveralls.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:coveralls 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/travis/.npm/_logs/2018-05-31T16_37_12_965Z-debug.log
The command "npm run test:coveralls" exited with 1. |
@jseminck, @tizmagik: nevermind, I think I've fixed it. The corresponding travis build, seems to have run the following without erroring: cat lcov.info | ./node_modules/coveralls/bin/coveralls.js I guess I'll merge my corresponding pull request, and see if my |
Ah, didn't have to wait for PR to be merged. Seems like the configurations worked. Thank you everyone, pretty much recycled different aspects from various comments in this issue. |
@nickmccurdy's solution worked for me. Thanks Nick! |
Based on @jeff1evesque and @nickmccurdy answer: package.json "scripts": {
"ci-process-cover": "cat coverage/lcov.info | coveralls"
} jest.config.js module.exports = {
"collectCoverage": true
// ...
} .travis.yml script:
- npm run test
after_script:
- npm run ci-process-cover Or have tests run twice: package.json
.travis.yml script:
- npm run test
after_script:
- npm run cover If you replace |
I've faced a similar problem, hope this post might help you a little bit. |
Hi all am facing
when running it locally and in my Github action. How do I generate .lcov so the file won't be empty? @nickmccurdy @jseminck @tizmagik |
@adefemi171 if you are using Angular |
Am using Node and Jest and I ran |
Because it doesn't work on Windows. Do we have any cross-platform solution ? I figured only following: jest --coverage && coveralls < coverage\\lcov.info Ordinary pipe |
Hi everyone,
is anyway i can setup this with Jest?
many thanks
The text was updated successfully, but these errors were encountered: