Browser page keeps refreshing when testing Backbone views with Jasmine

Viewed 1412

Running the following Jasmine test(1), the test is successfully performed but I face the recursive loading of the main test page.

Here is my test (1) and here the module on which I am running the test (2):

Any ideas? How can I fix the issue?

P.S.:
The issue regard just Chrome and Safari Browser.
Here is an example: jsfiddle.net/shioyama/EXvZY


(1)

describe('When Submit button handler fired', function () {
    beforeEach(function () {
        spyOn(MyView.prototype, 'submitForm');
        this.view = new MyView();
        this.view.render();
        this.view.$el.find('form').submit();
    });

    it('submitForm should be called', function () {
        expect(MyView.prototype.submitForm).toHaveBeenCalled();
    });
});

(2)

var MyView = Backbone.View.extend({
    events: {
        'submit form' : 'submitForm'
    },

    submitForm: function (event) {
        event.preventDefault();
        // some code
    }
});
1 Answers
Related