Janet Riley

I Take Exception to Your Exception

November 28, 2014 | In 30 days

Today's pesky Angular.js error occurred in a unit test for directives.

    TypeError: Attempted to assign to readonly property.
        at workFn (/blah/blah/blah/app/bower_components/angular-mocks/angular-mocks.js:2105)

The error is a red herring. It comes from reporting the error message, not the underlying cause. A tip of the hat to Akrikos for their comment.

workFn() is in the angular.mock.inject function. Among the many ways to cause an injector error are misspelling the service you want to inject and re-injecting something that's already present.

Some days cry out for the Benny Hill theme song.