Finding the perfect balance between visual layout and coding has been a nightmare for developers, a problem which AngularJS deals with so well that in just a brief time since inception, it has become a favorite of developers all around the world. It has rightfully earned the tag of being a ‘Superheroic’ framework thanks to the diverse range of features it provides, and also as it helps the developers to build powerful applications without compromising on the visual aspects. Along with being a fully-featured package, it also presents an outstanding ability to be tested, which further helps to manage the applications and keeps them up and running!
Learning AngularJS Testing will help you to understand the different aspects involved in testing components, such as controllers and directives, with the help of a practical pizza ordering application right from the start, all the way to the end!
We’ll start by constructing a project structure of our app, before installing and initializing various helpful tools such as Karma, Jasmine, and Grunt. We will create controllers for ordering the pizza, reviewing the order and test them be it with or without any dependencies. Not only that, but we will also go through testing the navigation between two controllers with the help of End2End testing. After that, we will create accordion directives for our application, unit test them, and resolve the errors if these tests fail. Furthermore, we will modify our services to use the $resource module and help them interact with REST API web services, as well as unit test them with the help of mocks and spies. Finally, we will create and test directives and controllers which fetch information from the service and display it.
At the end of the course, you’ll be familiar with the various approaches involved in testing AngularJS code and will be able to implement them to develop bug-free and maintainable applications.
About The Author
This video will offer the overview of the course.
We want to run and write unit tests to practice test-driven development. We will use a test framework and a test/task runner.
We have to set up project directories and other files. We will create the project structure.
We need to perform a unit test and an end2end test on the existing controller. We will configure the Karma test runner.
A controller needs testing and is self-contained. We will write unit tests for this.
A controller relies on a service. We have to make sure that the integration works. We will write unit and integration tests for it.
We need multiple controllers in an app. We have to make sure that they work together and the UI works for the user.
We require a custom user interface component. So, we will create a directive.
We need to make sure that the UI works automatically. We will write a unit test for it.
The directive influences user navigation or the UI appearance. We will test it at the integration level.
We want to interface with the REST API. We will use the $resource service that is included with AngularJS.
We require a fast way to test the REST API. We will create a server with fake data.
We need a useful directive. We will create a directive that is hooked up to a service.
We need a controller to communicate with the server. We will hook up a controller to the service.
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.