Testing backbone.js application with jasmine - how to test model bindings on a view?

前端 未结 6 1590
-上瘾入骨i
-上瘾入骨i 2020-12-24 02:48

I had some interesting tribulations in trying to test whether views were correctly bound to events.  In backbone, we typically bind to events in the initialize method, using

6条回答
  •  情话喂你
    2020-12-24 03:35

    I ran into the same problem and changed my Views code from:

    this.model.on('change', this.render, this);
    

    to:

    this.model.on('change', function () {
        this.render();
    }, this);
    

    And my jasmine tests worked as expected.

提交回复
热议问题