O'Reilly logo

AngularJS Testing Cookbook by Simon Bailey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Synchronous testing of animations

This recipe will show you how to test a JavaScript animation in a synchronous approach by creating a mock replacement for the event handlers using the $animateProvider service.

Getting ready

For this example, you'll need a JavaScript animation that runs with show/hide options. I use jQuery (http://jquery.com) for the animations and transitions based on the opacity. The following are the steps to create the recipe test example :

  1. Register a JavaScript animation via the myModule.animation() function. Also, create an object containing event callback animation functions that are triggered based on the ng-show animation event callbacks (https://docs.angularjs.org/api/ng/directive/ngShow#animations).
  2. Secondly, add a class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required