mardi 29 mars 2016

Backbone - testing views - how to handle baseview?

I want to test a Backbone.js view. All rather generic view methods (get template, get model data, render HTML) are stored in a baseview most of my views extend.

Question 1: Since the two – the view to test and the baseview - are separated, does this mean I don't need to test a view's render method because baseview's test should cover this? Or should I test every view's render method, even when this falls back to methods defined on the baseview, to test how the two play together?

Question 2: I am not sure how the baseview can be tested in isolation. If another view extends it, a template name needs to be set for the baseview to work. Should I just mock the template or treat this view like an abstract class that can't be tested in isolation?

Aucun commentaire:

Enregistrer un commentaire