Something that recently bit me, was we use a serialized json coloumn on a number of our backend models. So to replicate that in the front end, we have a number of factories like this:
The data column will then be used in various specs. Because of the way extend works, the collection map holds on to the default factory that contains a reference to data. As new factories are created, that same data in memory gets updated instead of replaced with a fresh object.
One potential solution is to update it to do a recursive clone, something like this: http://stackoverflow.com/a/728694/645132. Where it checks the typs, either does a return or creates a new object/array.
Something that recently bit me, was we use a serialized json coloumn on a number of our backend models. So to replicate that in the front end, we have a number of factories like this:
The data column will then be used in various specs. Because of the way
extend
works, the collection map holds on to the default factory that contains a reference todata
. As new factories are created, that same data in memory gets updated instead of replaced with a fresh object.One potential solution is to update it to do a recursive clone, something like this: http://stackoverflow.com/a/728694/645132. Where it checks the typs, either does a return or creates a new object/array.