Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:03:47+00:00 2026-06-11T09:03:47+00:00

I am writing tests for a web application using backbone and backbone.marionette through jasmine.

  • 0

I am writing tests for a web application using backbone and backbone.marionette through jasmine.

My questions are:
1) should I check the view when something change in the model to see if the view is affected?
2) if yes, what is the proper way…. for example in the following case (1)

P.S.:
I would like to avoid to change the template file


(1)

// template 

<ul class="widget-points-status">
    <li>
        <strong>{{ remaining_points }}</strong>
    </li>
    <li>
        <strong>{{ given_points }}</strong>
    </li>
    <li>
        <strong>{{ received_points }}</strong>
    </li>
</ul>

// My jasmine test could be:

describe('Changing the model:', function () {
    beforeEach(function () {
        app.currentUser.set({
            given_points: 111980,
            received_points: 892378,
            remaining_points: 435412
        });
    });

    it('it should change the points', function () {
        var pointsView = this.view.$el.text().match(/\d{1,}/)[0];
        expect(pointsView).toMatch(app.currentUser.get('given_points'));
        expect(pointsView).toMatch(app.currentUser.get('received_points'));
        expect(pointsView).toMatch(app.currentUser.get('remaining_points'));
    });

});

var pointsView = Backbone.View.extend({

    className: 'widget widget-profile',

    initialize: function () {
        app.currentUser.on('change', this.render, this);
    },

    render: function () {
        this.$el.html(profileTemplate(app.currentUser.toJSON()));

        return this;
    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:03:48+00:00Added an answer on June 11, 2026 at 9:03 am

    If your view listens to model events, you can use a spy to check if your listener is called when you change the model.

    describe("A Backbine View", function() {
    
        beforeEach(function() {
            spyOn(pointsView, "changePoints");
        });
    
        it("should listen to model changes", function() {
            app.currentUser.set("points", 2);
            expect(pointsView.changePoints).toHaveBeenCalled();
        });
    });
    

    Of course the same concept applies if you have render as the listener.

    Personally I wouldn’t check the rendering explicitly in Jasmine since this will only ever work if you run the tests in a browser. If you use Jasmin for Maven for example you have Rhino and therefore no DOM to work with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's the best strategy to use when writing JMeters tests against a web application
I'm writing WatiN tests to test an Ajax web application and have come across
I am writing robot tests for web testing using Google's Robot Framework with SeleniumLibrary
I'm writing automated UI tests in C# using Selenium 2 Web Driver for web
I'm writing a web application in python, and using lettuce with splinter to write
I'm writing a web application using a <canvas> element. For simplicity, I have stripped
I'm writing a mobile web application using JQuery Mobile, JQuery, Javascript. This is my
I have just started writing a web application. I am using GIT for version
I'm writing some codedUI tests in VS2010 to test a web application. I'd like
I'm writing some JUnit-based integration tests for a RESTful web service using JerseyTest. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.