Recently updated angularjs app from 1.5.11 to 1.8.2
This broke several of our unit tests. All seem to be throwing the error:
TypeError: Attempting to configurable attribute of unconfigurable property.
After some debugging, this happens whenever one of our directive specs calls $compile()
Here's a copy of one of the calls a directive spec makes:
element = angular.element('<input id="labels" type="hidden" ui-select2="select2Options" ng-model="labels">');
compiled = $compile(element)(scope);
$(document.body).append(element);
element.scope().$apply();
I've looked through the documentation and the only reference I found relating to a change in $compile has to do with the removal of the preAssignBindingsEnabled function. It looks like before 1.6, this was on by default. In 1.6 it was turned off by default, but supported if you explicitly set the flag. Starting in 1.7, you were no longer able to set the flag.
I am unsure if this is the cause of my issue, but reading through the documentation, I'm not sure that this change is actually relevant? The code compiles and works as expected, it's just the test that complains. Any help is greatly appreciated!
CodePudding user response:
This is a quick work around, but might help for determining the final solution:
To work around this problem we downgraded angular-mocks-1.8.2.js to angular-mocks-1.6.4.js, as it appears something in our unit testing chain appears to be using the compileProvider.preAssignBindingsEnabled() method.
We also upgraded Jasmin/Karma to the latest version, but not sure if this is really part of the solution.