I am having a JS-Data resource in angularjs, and every time I call inject
on it in a (Jasmine) test, the test slows down, taking up to 700ms.
I am already doing an ejectAll()
after each test. It is not doing any $http
requests either, so I am out of clues...
Any ideas why JS-Data injections might be so slow in my tests?
Found it: in my resource definition I set the
UseClass
property to a model that changed the instance, replacing an array with a getter throughObject.defineProperty
. As stated here:The getter resulted in JS-Data to think the instance changed, triggering an infinite digest loop. After 10 digests angular gives up, but it takes some time, leading to slow tests.
Lesson learned: don't extend persistend DS model instances with getter properties, as they trigger infinite changes.