I am trying to simulate user actions and test AngularJS controller reaction on them.
describe('Testing a controller component', function () { beforeEach(inject(function ($compile, $rootScope, $httpBackend, $templateCache) { scope = $rootScope.$new(); element = angular.element('<sign-up></sign-up>'); element = $compile(element)(scope); scope.$digest(); controller = element.controller('signUp'); scope.$apply(); })); it('should render template', function () { element.find('input').val('123'); scope.$digest(); expect(controller.firstName).toBe('123'); }); });
The test fails due the model field is not updated.
Expected undefined to be '123'.
at UserContext.<anonymous> (tests/calculator.controller.test.js:54:42)
I know it's against the AngualrJs approach, but I wan't use it for testing.
Aucun commentaire:
Enregistrer un commentaire