We are creating a test framework for a Angular Web API Project. I have researched about Testing frameworks like Jasime, Mocha etc.
My question is, do we need a test runner like karma along with Jasime/Mocha to run & test test cases.
Yes, karma will be the test engine that will run your jasmine tests. Jasmine is a test API / framework, karma is a test engine that will spawn javascript environments able to run your tests.
You can run your tests just straight in an HTML page, but it's easier to just use karma. You need to use something like Karma if you're going to test directives, because you need the html2Js preprocessing.
Related
I've seen examples using grunt with protractor coverage, but i'm using gulp and the same with karma.
How do I use protractor with karma and gulp.
Thanks.
I'm going to use the following generator
https://github.com/Swiip/generator-gulp-angular
In my project there is RESTful web services and I am using angularjs for front-end. But I am not able to figure out how to test angularjs in eclipse environment.
Is there any way to achieve it?
I have already install karma.
My sugestion would be to use Jasmine tests.
http://jasmine.github.io/
As you already installed karma, you can automize a grunt taskt "test", for instance, to write all the tests.
This approach is independent from eclipse, you can use it with a terminal.
Can Protractor be used for Test Driven Development of Angular JS Application ? Protractor is popularly used as E2E test framework for Angular but can we use it for TDD (Test Driven Development) ?
Protractor should be used only for E2E testing.
For TDD you can switch to Karma with Jasmine.
Also see http://kroltech.com/2013/11/javascript-tdd-with-jasmine-and-karma/
I use Protractor in my TDD workflow but not for unit tests. I use it for tests similar to integration tests which require interfacing with a running site.
I wouldn't use it for unit tests because it is so much slower than Karma as a test runner and it requires the server to be started.
I wrote a little about my experiences doing TDD in Angular which shows how I use Protractor vs Karma. I hope it helps.
What are my options for testing if I want to run an angularjs app in node-webkit?
I had a look at the nw docs for testing and they did not really make sense to me https://github.com/rogerwang/node-webkit/wiki/How-to-run-node-webkit%27s-test-cases
This module was very useful for me in testing angular with nodewebkit - nwjs test runner
I am using karma and jasmine for testing my node-webkit applications. There is a karma-node-webkit launcher which makes it possible to run those tests.
Your link describes the tests for node-webkit itself.
There's a different wiki page for testing your own app: Testing framework for your application running on node-webkit
Is there somewhere an example of AngularJS app generated by yo angular generator that has e2e tests with $httpBackend from ngMockE2E module? Preferably with single and continuous versions for CI and development.
It looks like using $httpBackend requires one to create a new app that depends on the original app module and ngMockE2E module and requires new index.html file that loads this new app.
If tests use a different app, does it mean that I should modify configuration to store files generated for tests somewhere else than files generated by grunt server command (.tmp), or will these files be exactly the same? I'd like to be able to have grunt server running for development while running e2e tests in the background with PhantomJS.
Has anyone created a task that automatically generates modified index-e2e.html file based on index.html? This way it would be always up to date and it could also be used with watch to automatically regenerate it whenever original index.html file changes.
You should notice that angular is depreacting e2e in favor of the protractor framework.. Also notice that e2e (and protractor also) is quite slow. so running continuously in the background like we do with unittesting isn't recommended. That said, for your question - No you don't need a different app, index file etc. (unless you need coverage data from e2e, in that case you'll need to instrument the js files, and that would require a different index.html, that can be created in grunt task with sed). what you do need is a different karma.conf.js file, a different grunt karma task ro reference it, including ng-scenario in the files section of the karma.conf. and running some kind of grunt testServer task that would run a test server, which isn't the same as the dev grunt server. You can run both with foreman or something similiar (as explained in this SO [question]. (How can I automate both E2E and unit tests with Yeoman & AngularJS?) and answer). If this is what you are looking for - you can find a karma.conf.js example for both e2e an unit in this PR. and again, don't invest heavily into the current e2e framework. better working the the new and shiny protractor