Karma testing: TypeError: Attempted to assign to readonly property Karma testing: TypeError: Attempted to assign to readonly property angularjs angularjs

Karma testing: TypeError: Attempted to assign to readonly property


readonly error is caused by scope.page(in my InformationController) being undefined and then the code is trying to assign a property to undefined.Hence the modified beforeEach block as below

beforeEach(inject(function ($controller, $rootScope) {        scope = $rootScope.$new();        scope.page3 = {};        InformationController = $controller('InformationController', {            $scope: scope        });    }));

This solved the issue.