Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS Test Example [closed]

I don't know why but I'm finding it really difficult to get my head around setting up a JavaScript test using AngularJS.

I have my app.js, controller.js plus a number of other files for Ajax, Storage services, filters etc. My app works fine but I want to learn how to do E2E and unit testing.

I think I need to create a standalone HTML page that runs my tests, but I'm not sure, I'm also not sure which extra JavaScript files/libraries I might need.

Is there an AngularJS test example I could use to get the initial set-up?

Ideally I'd like to run the JS tests I create from within Visual Studio 2012...but that's a nice to have!

like image 483
Greg Avatar asked Sep 20 '12 08:09

Greg


People also ask

How do I test my Angular application?

If Angular CLI is used to manage the Angular projects, it will automatically support Jasmine and Karma Configurations. All you need in order to test your application is to type the command ng test.


3 Answers

I find this tutorial a good start.

http://www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-testacular.html

It not only teaches how to do unit testing but also E2E and a special one ...Midway testing. A good reference IMHO.

like image 162
skeep Avatar answered Oct 16 '22 17:10

skeep


I recomend you to look at angular-seed project. It has e2e test already setup. https://github.com/angular/angular-seed

like image 34
Tosh Avatar answered Oct 16 '22 15:10

Tosh


AngularJS dev guide has a complete page on the subject: http://docs.angularjs.org/guide/unit-testing

There is also a blog post mentioning a sample app in github including Testacular tests here: http://blog.angularjs.org/2012/11/angularjs-example-applications.html

Hope it helps.

like image 8
OCarneiro Avatar answered Oct 16 '22 16:10

OCarneiro