Skip to content Skip to sidebar Skip to footer

How To Unit Test An Angular 1.5 Component Template?

So, here's my test: describe('My Test', function(){ var $componentController, $compile, controller, scope; beforeEach(inject(function($injector, $rootScope, $templateCache){

Solution 1:

scope.foo doesn't affect component bindings. foo scope property is not foo attribute.

This likely should be tested like

var component = $compile('<my-component foo="{{ foo }}">')(scope);

scope.$digest();

var componentScope = component.isolateScope();

expect(component.html())...
expect(componentScope.$ctrl.foo)...

Post a Comment for "How To Unit Test An Angular 1.5 Component Template?"