using Code coverage using QUnit and Teamcity - javascript

Actually I am in the process to run my javascript code on teamcity using QUnit+ phantomjs.
(using this link as reference:http://thomasardal.com/running-qunit-tests-on-teamcity/)
And at least the execution of my tests using phantomjs looks ok on my local machine so in someway I am happy :). But that is not all what i want to do, I would like to add code coverage to my javascript tests and run it from our Teamcity server. is there some way to do that? jscoverage is an alternative?
thank you!

As to TeamCity side of the question, here are some notes in the doc on how external coverage results can be integrated into TeamCity.

Related

JavaScript unit test using Jenkins

I am actually configuring Jenkins to make a continuous integration of a JS project with unit tests. My problem is that after many researchs I didn't found any tutorial or information about how to proceed to write unit tests in Jenkins.
Should I use other tools (grunt, ant...) with Jenkins or could it do the job alone ? Is there any important plugin to install to make it work ?
Thanks for your answers
What you're looking for is a testing framework with a JUnit Reporter. Jenkins can read your test results from the JUnit report and give you metrics from them.
Jenkins is just for handling the automation of building your code and running your tests in whatever language you need. In order to use it for that, you need to use something like Karma, Mocha, HapiJS's Lab, Unit.js, Jasmine, etc. to actually write and test with.

Jenkins JavaScript Testing and Code Coverage report

We run a CI environment with Jenkins and the Project using ExtJS 5.1.1.
I try using Chutzpah test runner, using mocha framework JavaScript unit test.
With JavaScript test without ExtJS 5.1.1 testing run successfully.
But JavaScript with reference ext-all.js, there are no success. We have time out error in Blanket.js (error blanket_mocha.js line 5141‏) testing are not succeed and coverage.xml won't generate.
I'm looking for other way how run JavaScript test (ExtJS) in Jenkins with mocha framework and have code coverage report generate.
We already have Grunt run in Jenkins to do JavaScript combine and minify.
Is this possible to using Grunt to run mocha test and generate coverage.xml in Jenkins?
Please help me out if there is some other way to achieve the same thing. Any suggestion are highly appreciated.

Code coverage for nightwatch.js using Istanbul

Has anyone got code coverage to work for nightwatch.js with Istanbul. Any helpful links to the configuration will be appreciated.
nightwatch.js is a wrapper on Selenium. I believe what you attempting is not going to work with nightwatch.
See also
Selenium: Is there any JS (JavaScript) code coverage tool which we can integrate with Selenium Server/RC where one user recommended JsTestDriver instead.

Serverside JS coverage for IntelliJ

Is there a way to run code coverage without browser in intelliJ?
http://www.jetbrains.com/webstorm/webhelp/monitoring-code-coverage-for-javascript.html
This is only coverage tutorial by Jetbrains, but both of these require a browser, so i can't test my Node.js code. I bet i'm not the only one who want's a coverage report of their Node.js code using IntelliJ :)
Karma and JsTestDriver seems both to run tests in browser so no Node.js code can be tested with those. I can anyways run mocha tests straight from idea, but without coverage.
There is no such feature in WebStorm. Please vote for WEB-10373
Edited 2018
It's been possible already quite a long now. Works out of the box for jest, and apparently very easy for mocha/istanbul too, see:
https://www.jetbrains.com/help/idea/running-unit-tests-on-mocha.html#ws_mocha_code_coverage
https://www.jetbrains.com/help/idea/running-unit-tests-on-jest.html#ws_jest_code_coverage

How can we run JavaScript jasmine tests from Jenkins (Hudson) without loading a JSP?

We have a rich web client. Our controllers and service facades are written in coffeescript (JavaScript) and jquery. In the past they would have been java.
To run our JavaScript jasmine tests from Jenkins/Hudson, we use java's junit and htmlunit to load a test oriented jsp page which includes the jasmine specs.
When the Htmlunit tries to run, it blows up trying to getPage() probably because of an XML parser class path which is extremely challenging to track down in our world.
We just want to be able to run our JavaScript tests from Jenkins and have it report failure if a JavaScript test does not pass. We are just using jsp and htmlunit in order to run JavaScript tests. Can we load the JavaScript tests and javascript code into a JavaScript engine with Jenkins as the thing that kicks it off? If so, how?
Sounds like you're in a Java environment. My jasmine-maven-plugin might be a good fit.
Jasmine Reporters would also be a solution. It has instructions for running headlessly via PhantomJS for example, and it can generate JUnit XML so Jenkins can understand the test results natively, graphing test count, duration, and failure over time.
Also, the "xvfb-run" wrapper often provided with xvfb is a great help here, so you can do "xvfb-run phantomjs.runner.sh ..." in a truly headless environment.
I've previously solved this problem by running the tests with a node.js plugin called jasmine-node
This solution of course requires node.js and a few node modules to properly run the jasmine tests. There is no real browser running the tests, but an emulated one using a module called jsdom, which basically creates a headless browser, and more specifically, a DOM, which the tests can interact with.
There's node modules for jQuery, underscore and propably other too, so these can be tested too. You can even skip the whole browser emulation if you'd rather run the tests in a browser, though I find it too cumbersome compared to automated Jenkins testing.
jasmine-node generates jUnit test reports, which Jenkins can interpret just fine.
I just realized there is some jenkins-jasmine-node plugin that might ease this process.
Grunt is your friend
use grunt http://gruntjs.com/
with grunt jasimine https://github.com/gruntjs/grunt-contrib-jasmine
with nodejs http://nodejs.org/
on jenkins using https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
got this setup and it's really nice, plus this gives you a place to start making your build server do other nice things such as deployment, unit testing, etc you know, other nice things
Can you use selenium? That would actually use a real browser then and get as close to the real environment as possible.

Categories