Learn how to test AngularJS components, including controllers and directives, and REST API services, using testing tools like Karma, Jasmine, and Grunt.
(piano intro music) (click) - [Rudolf, voiceover] Hello, and welcome to Learning AngularJS Testing by Packt Publishing. I'm Rudolf Olah, your presenter for this video course. I run the learning AngularJS newsletter and have been a web developer for the last five years, working with Rails, Djando, and NodeJS. AngularJS is an amazing technology because it provides a framework with the basics included.
It gives you everything you need to make good, responsive, high quality web apps. In this series of screencasts, we will be learning how to fully test an AngularJS web app. The web app is a pizza store from which customers can order a pizza. We will learn how to unit test and end2end test this application. In the follow videos of section one we will begin with setting up the app with a single controller and the testing infrastructure for running unit and end2end tests.
In section two, we will be creating controllers for our app and testing them, with and without dependencies, using mocks. We will also be conducting an end2end test event. In section three, we will be testing directives. Directives are the html components that contain their own logic, which need to be fully tested using unit tests. Designing an end2end test for a directive is covered in this section. In section four, we use mock objects to test the service that relies on the resource module and uses a rest API.
We hook the service up to a directive and to a controller and test those as well. You'll need your text editor and a web browser. So let's begin this journey together, and I hope to see you there.
AngularJS offers the perfect balance between layout and code, making the framework a favorite of developers around the world. But what you might not know is that Angular also provides an outstanding infrastructure for testing, for developing bug-free and easily maintainable applications. Learning AngularJS Testing helps you to understand the different aspects involved in testing Angular components, including controllers and directives, with the help of a practical pizza-ordering application.
Author Rudolf Olah starts by installing and initializing various helpful testing tools, such as Karma, Jasmine, and Grunt. Then he creates controllers for ordering the pizza and reviewing the order, and tests them with and without dependencies. Chapter 3 shows how to create accordion directives for the application, unit test them, and resolve the errors if these tests fail. Rudolf also goes through testing of the navigation between two controllers with the help of End2End testing. Finally, learn how to modify services to use the $resource module and interact with REST API web services, as well as unit test them with the help of mocks and spies. Rudolf also shows how to create and test directives and controllers that fetch information from the service and display it.
- Configuring Angular, Grunt, Karma, and Jasmine for testing
- Testing controllers
- Testing directives
- Inspecting the navigation between components with End2End testing
- Creating REST API services and unit testing them to make your app compelling and user friendly