Coveralls.io with Travis-CI - node.js

I have several open-source projects that use Travis-CI to check the build status on my commits. I also report my test coverage to Coveralls.io. In the past few weeks, the reliability of coveralls has been spotty at best, and I had my tests running the coverage stuff, but they would fail the build because the coveralls api was returning a 503 error.
In response to this, I moved my coverage stuff to an after_success script in my .travis.yml, but now it seems that it's not sending the info to Coveralls.io. Am I approaching this the wrong way? Has anyone else run into this issue?
Here are some more details on the projects I'm running into issues with:
all of them are node modules
all of them are tested using mocha
all of them have test coverage using istanbul
I am using the node-coveralls module to report coverage reports to coveralls.io
If more information is needed, please let me know.
UPDATE:
Now it seems to be reporting correctly to coveralls, but it's only reporting 50%. Any additional help would be much appreciated

I use the following in my yml file. It concats the lcovs from karma and mocha, then sends them along.
after_script:
- ./node_modules/karma/bin/karma start
- istanbul cover ./node_modules/mocha/bin/_mocha server/api/**/*.spec.js
- cat ./coverage/lcov.info ./coverage/karma/**/*.info > lcov.info
- node node_modules/lcov-filter/index.js lcov.info config | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage

Related

resemblejs "npm run test" tests not passing, can't extend timeout

I have cloned the repo for the resemble.js project code (https://github.com/rsmbl/Resemble.js#readme) and have been attempting to test the software by using the "npm run test" command. The test suites fail and it does not accept "jest.setTimeout(20000)" as a command to adjust the tests. I think I may be missing some packages but I don't know what they are.
Test results.
Any input would be very much appreciated.
Please Go To That Folder where you have cloned the repo
And Run a Command called :
npm i or just npm install
This should fix it !
:)
Have a great day / night ahead !

Why when test fails jenkins still says success?

I have a MEAN project. Using Jenkins on an EC2 machine I build this using the following shell script:
npm install && PORT=8888 npm test
mocha returns 2 (number of failing tests) but still jenkins says:
Finished: SUCCESS.
If tests are failing I expect to see
Finished: FAILURE
Do you know why its not working fine?
You can:
Use a test runner like Karma, or
Tell Mocha to report in, for example, XUnit format, by passing Mocha the --reporter xunit flag. XUnit closely aligns with JUnit which Jenkins understands, or
Add in a custom reporter — mocha-jenkins-reporter is a decent option.
In the end I used a different solution: installed Jenkins Text Finder and if "expected - actual" is found in log (test failed), I let this plugin to mark the build as "Unstable".

Jasmine tests through bamboo?

I would like to integrate the jasmine tests with bamboo, but I'm not sure is it possible.
The best what I found so far is https://bitbucket.org/atlassian/bamboo-nodejs-plugin which support just mocha tests. I would like to know is there any way to change node-jasmine output to be compatible with bamboo.
Thanks
Resolved:
Using option --junitreport and than use that report in bamboo to show the results,
This is 3 years too late, but hopefully it can help some other people aswell.
For Karma you can use karma-junit-reporter npm package.
install it and add this to your Karma config file
config.set({
reporters: ['progress', 'junit'],
...
Then you can run your test and it will generate a JUnit xml file.
Use the JUNIT parser in bamboo and read this file. It should pick up your tests then.

Karma mocha and jscoverage

We have an application written in coffee-script with node.js and are struggling to set up code coverage tools.
At the moment we have code-coverage up and running for the serverside with
coffeeCoverage
jscoverage
mocha
The front end unit tests are functions with the karma test runner and mocha, and working well. But I just can't seem to find a way to get the same kind of output from karma.
Here is the command being used for the serverside:
mocha --compilers coffee:coffee-script --require chai --reporter html-cov --recursive test/mocha > coverage.html
it would seem that because the front end is also in mocha and coffee-script we should be able to do the same thing there. But karma does not support the html-cov reporter, and that has left me at somewhat of a dead end.
The ideal path is that karma would run like normal in phantomjs and use the mocha html-cov reporter to output an html file. Does anyone know were to go from here?
Here is a portion of my Cake task for the serverside just for reference.
karma-coverage plugin uses Istanbul to instrument the source files and generate the coverage reports.
There's a pending issue to enable the same for coffee script too https://github.com/karma-runner/karma/issues/622
I highly recommend switching from jscoverage to istanbul to calculate your code coverage. istanbul supports mocha (be sure to call _mocha) and is the default code coverage tool for karma. Details here: Code coverage with Mocha

using Blanket.js for a compoundjs app to generate coverage report

I have compoundjs application in which I have used the scaffold generator to generate controller and its test cases. The test cases are running correctly. But I need to generate the code coverage report for the same. I am trying to use blanket.js for the same.
I have configured blanket.js like this in package.json in scripts :
"blanket": { "pattern": "app" }
app is the folder which contains all my controllers, models etc. And then I am running test cases having reporter as :
mocha test/init.js test/controllers/sample_controller.test.js --require blanket -R html-cov > coverage.html
This is actually properly generating coverage report for it. But the problem I am facing is it is only showing the code coverage for certain files like it is showing code coverage for model/sample but not for controllers/sample_controller.js.
Please help me out ASAP as I am actually stuck with it.
Thanks a lot in advance,
Option 1: Try using _mocha instead of mocha to avoid mocha forking and not covering all of your code in the same process.
Option 2: I highly recommend istanbul as a coverage tool. Try:
npm -g install istanbul
istanbul cover _mocha -- test/init.js test/controllers/sample_controller.test.js --require blanket -R spec
open coverage/lcov-report/index.html
More info here: https://github.com/gotwarlost/istanbul/issues/44
These are eval controllers, right? I'm investigate coverage for eval controllers in the next release of Blanket (v1.1.3). In the meantime Istanbul is an option, as is grunt-blanket.

Resources