0

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?

SiddAjmera
  • 38,129
  • 5
  • 72
  • 110
Raymundus
  • 2,173
  • 1
  • 20
  • 35

1 Answers1

0

Found it: in my resource definition I set the UseClass property to a model that changed the instance, replacing an array with a getter through Object.defineProperty. As stated here:

The DS.change fires on a Resource whenever any item in the Store for that Resource changes.

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.

Raymundus
  • 2,173
  • 1
  • 20
  • 35