Synyzapo

  • Components from AngularJS are reused throughout the application, and for that is very import to properly test them.
  • ngMock module provides a helper service called $componentController that allows us to create our component controllers, to be easy for us to unit test them.
  • beforeEach setup: var $componentController; beforeEach(module(‘MyApp’)); beforeEach( inject(function(_$componentController_) { $componentController = _$componentController_; })) Test method: it(‘should update value’, function() { var bindings = { prop1: { val: ‘myValue’ } }; var ctrl = $componentController(‘myComponent’, {}, bindings); var updateValue = ctrl.val; expect(updatedValue).
  • Software Development JavaScript AngularJS
  • x


Components from AngularJS are reused throughout the application, and for that is very import to properly test them. ngMock module provides a helper service called
$componentController that allows us to create our component controllers, to be easy for us to unit test them.


@synyzapo: Testing AngularJS 1.x components: #angularjs #javascript #frontend

Posted on January 23, 2017

Components from AngularJS are reused throughout the application, and for that is very import to properly test them. ngMock module provides a helper service called $componentController that allows us to create our component controllers, to be easy for us to unit test them.

Synyzapo

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.