0
각도로 애니메이션을 테스트하는 방법을 아는 사람이 있습니까? $ animateProvider 또는 angular.module ('', []) 중 하나를 사용하여 만든 애니메이션. animate()? 저는 애니메이션 라이브러리를 만들고 있는데, 좋긴하지만 $ animate를 사용하여 애니메이션을 테스트 할 수있는 적절한 방법을 찾을 수 없습니다. 그들은 일하지 않는다. 해킹 당해서 작동하지만, 각 테스트의 모든 애니메이션을 재현하고 있습니다. 내 애니메이션이 아닌지 확인하기 위해 테스트에서 새 애니메이션을 만들었습니다. Angular의 소스 코드에서 바로 이것을 얻었지만 여전히 작동하지 않습니다.애니메이션 테스팅 애니메이션 1.2+
describe('Testing Async Animations', function() {
var am = false;
beforeEach(module('ngAnimate'));
beforeEach(module('ngAnimateMock'));
beforeEach(module(function($animateProvider){
$animateProvider.register('.fade', function(){
return {
enter: function(element, done){
console.log('here');
am = true;
done();
}
};
});
}));
/* the done() method is something mocha provides.
to make this work in Jasmine, just follow their
example with using a asynchronous test */
it("should asynchronously test the animation", function() {
inject(function($animate, $compile, $document, $rootScope, $rootElement) {
var element = $compile('<div class="fade">hello</div>')($rootScope);
$rootElement.append(element);
angular.element($document[0].body).append($rootElement);
$animate.enabled(true);
$animate.enter(element, $rootElement);
$rootScope.$digest();
expect(am).to.be(true);
});
});
});
"그들은 결코 작동하지 않습니다". 테스트 또는 애니메이션? 그리고 어떤 방식으로 작동하지 않습니까? 작동하지 않는 테스트중인 예제 애니메이션을 제공 할 수 있습니까? 플 렁커 (Plunker)가 여기에서 매우 도움이 될 것입니다. 또한 Angular의 테스트를 복사하고 테스트에서 애니메이션을 재생성한다고 언급 한 사실은 잘못된 것을 테스트하고 있음을 나타냅니다. Angular의 테스트는 API (예 :'enter' 함수)가 필요할 때 실행되는지 확인합니다. 테스트는'enter' 함수 내에서 일어나는 일의 행동을 검증해야합니다. 애니메이션 코드를 Plunker에 게시하면 도움이 될 것입니다. –