As part of my unit tests (using QUnit) for a backbone project, I test some collection manipulation functions that return arrays of backbone models.
Is there a way to directly test (for sanity’s sake) whether the objects in my array extend Backbone.Model or should I just do a duck type check (and if so, how, and on which unique attribute, for example)?
Since there is no real “Class” construct in javascript, typeof obviously won’t do the trick here.
I could see this being useful in other tests down the road for my Collections, or to check that things are instances of my specific Backbone classes, etc.
How about using
instanceof: