2

As suggested on the Protractor page I tried adding the following in my config file:

onPrepare: function() {

    var disableNgAnimate = function() {
        angular.module('disableNgAnimate', []).run(['$animate', function($animate) {
            $animate.enabled(false);
        }]);
    };

    browser.addMockModule('disableNgAnimate', disableNgAnimate);

    browser.getCapabilities().then(function(caps) {
        browser.params.browser = caps.get('browserName');
    });
}

And it did not turn off the animations.

I am dealing with a website that is heavily animated and this screws my tests a lot..

P.S. I am using the TypeScript definition for Protractor, does this matter?

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Darkbound
  • 3,026
  • 7
  • 34
  • 72
  • Check-out this topic, it might be helpful: http://stackoverflow.com/questions/26584451/how-to-disable-animations-in-protractor-for-angular-js-appliction – Sergey Teplyakov Aug 24 '15 at 12:44
  • I have found this topic before I posted my question and I could not find any different information from what was on the Protractor page. – Darkbound Aug 24 '15 at 14:00

1 Answers1

1

You disabled just ng-animations.

For me is much better to make animation duration 1ms instead of turning it off. (becuse of some animation event handlers in code)

Try code below it will accelerate CSS animation, so it can solve your problem

onPrepare: function () {
    // disable animations when testing
    var disableAnimation = function () {
        angular.module('disableAnimation', []).run(function ($animate) {

            // disable css animations
            var style = document.createElement('style');
            style.type = 'text/css';
            style.innerHTML = '* {' +
                '-webkit-transition-duration: 1ms !important;' +
                '-moz-transition-duration: 1ms !important;' +
                '-o-transition-duration: 1ms !important;' +
                '-ms-transition-duration: 1ms !important;' +
                'transition-duration: 1ms !important;' +
                '-webkit-animation-duration: 1ms !important;' +
                '-moz-animation-duration: 1ms !important;' +
                '-o-animation-duration: 1ms !important;' +
                '-ms-animation-duration: 1ms !important;' +
                'animation-duration: 1ms !important;' +
                '}';
            document.getElementsByTagName('head')[0].appendChild(style);

            // disable angular ng animations
            $animate.enabled(false);
        });
    };

    browser.addMockModule('disableAnimation', disableAnimation);
}
Alex Cap
  • 113
  • 9