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!
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.
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.
I recomend you to look at angular-seed project. It has e2e test already setup. https://github.com/angular/angular-seed
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With