JavaScript Unit Tests with Team Foundation Server Build - javascript

We are using Team Foundation Server 2010 and we have some JavaScript unit tests running on our local machines using Jasmine.
We are using the workflow based builds.
Has anyone had any success running Jasmine tests during their builds? Can you break the build if the Jasmine tests fail?

The way I've seen this done is using the Chutzpah Test Runner available on CodePlex: http://chutzpah.codeplex.com/
This allows you to run Jasmine/QUnit tests from a command-line which can then be easily integrated with a TFSBuild using the InvokeProcess Activity.

you should checkout http://www.codit.eu/blog/2015/03/18/continuous-integration-with-javascript-nunit-on-tfsbuild-(part-23)/
The blogpost describes a complete scenario how to execute your JavaScript Unit tests on the Team Foundation Build server. Basically it uses Grunt (taskrunner) and Powershell. It also has an example of code coverage reports that you can use.

Related

Does Karma coexist with Jasmine?

From the online definition:
Karma: is a tool which spawns a web server that executes source code against test code for each of the browsers connected. The results of each test against each browser are examined and displayed via the command line to the developer.
Jasmine: is a development framework for testing js code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.
My question is, does Karma require Jasmine to run, does Karma depend on Jasmine since Jasmine is a framework and Karma is a tool which runs on that framework and runs the written tests?
I'm using both of them with my angular2 project.
Karma is client-side test runner and doesn't depend on Jasmine. It can run without any testing framework at all.
It has plugins for major testing frameworks, including Jasmine and Mocha.
Yes, Jasmine and Karma can co-exist.
Jasmine is a javascript based framework that we use to write unit
test cases. Alternative to jasmine is Mocha.
Karma is a test runner, which runs unit test cases on browser. And It can be used with all type of unit test frameworks. And It's easy to integrate with all CI tools like Bamboo and Jenkins.

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.

Current State of Crossplatform JavaScript Unit and Systems Testing

For JavaScript projects, what asynchronous system and unit test framework would be most conducive to use in both node.js and web browsers.
Ideally, the testing system would be able to execute some tests specifically for node.js and some in web browsers, while also having general tests which run in all environments.
Also, does anyone make automatable browser tests?
There are a bunch of unittest frameworks for JavaScript:
Jasmine
BDD style
for both node and browser testing
can run via maven, so you can used with CI (Jenkins)
BusterJS
its in beta state
BDD style
for both node and browser testing
Generates JUnit/Ant compatible XML output for use in continuous integration servers (Jenkins)
JSTestDriver
Plugins for eclipse and IntelliJ/Webstorm
runs in the browser , result saved on the server
calc code coverage

Unit testing in RequireJS and QUnit basics

I am just trying to get my head round unit testing in Javascript and RequireJS. I am building a web-app and obviously only want to have tests run in development not production builds.
Questions:
Do you just test when you want to, or do you have JS tests running
on every page load when in development?
If tests are only on demand
then how do you trigger your tests to run? Query strings (eg.
?testing=true) or something like that?
I just need an idea of how people go about testing in development. I am using BackboneJS, RequireJS and jQuery on the front end with a NodeJS/ExpressJS server on the backend.
For a Backbone project at work we have a maven build process that runs our automated javascript tests through jsTestDriver, and we read the results with Sonar. I usually run the tests manually (with 'mvn test'), but I could easily tell maven every time I save a file, for example. I wrote a post that shows how to integrate QUnit, Requirejs, and code coverage with JSTD that is independent of Maven: js-test-driver+qunit+coverage+requirejs. It also contains links to a QUnitAdapter that is way more up-to-date and developed than the one on the jsTestDriver site. I'll update this post when I manage to write about how I got jsTestDriver working with Maven and Sonar. Hope it helps.
Grunt is a popular JS build tool. There's something called grunt-watch that can monitor certain files for change, and execute tasks accordingly. You could easily run unit tests with something like this on every save.
Usually end-to-end tests take longer, and we use the CI for that. I've seen a presentation on Meteor TDD that does end-to-end tests after every save though.
There are many end-to-end test frameworks, and they can run in a headless browser like phantom js using a build tool like grunt. Some frameworks open an actual browser to run the tests, but run via command line and report results using XML.
If you break out your components enough, the tests could have a small enough scope to run on each save.
For some core code I use JsUnit + Rhino on build server. For more complex bits (usually interface) I use selenium (it also runs on build server). I don't test anything on page load, I only use not-compressed versions of scripts.
I don't any solution for integration tests.

Categories