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 6959595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:17:33+00:00 2026-05-27T15:17:33+00:00

I was trying to learn the ways of testing Backbone-based app using Jasmine. For

  • 0

I was trying to learn the ways of testing Backbone-based app using Jasmine. For this, I picked up some sample code from here: http://msdn.microsoft.com/en-us/scriptjunkie/hh377172.

    Photo = new Backbone.Model.extend({
        defaults:{
            title: 'Another photo!',
            tags:  ['untagged'],
            location: 'home',
            src: 'placeholder.jpg'
        },
        initialize: function(){
            console.log('this model has been initialized');
            this.bind("change:title", function(){
                var title = this.get("title");
                console.log("My title has been changed to.." + title);
            });
        },

        setTitle: function(newTitle){
            this.set({ title: newTitle });
        }
    });

Then wrote the test spec as follows:

    describe("Photo Model", function() {
        it("verifies title", function() {
        var myPhoto = new Photo();
        myPhoto.set({ title: "On the beach" });   
        expect(myPhoto.get("title"))
            .toEqual("On the beach");
        });
    });

While running it, the test fails with TypeError

    TypeError: Object [object Object] has no method 'apply'
        at new <anonymous> (http://localhost:88/backbone/WebClient-Backbone2/js/backbone.js:1103:41)
        at [object Object].<anonymous> (http://localhost:88/backbone/WebClient-Backbone2/test/spec.js:28:16)
        at [object Object].execute (http://localhost:88/backbone/WebClient-Backbone2/test/lib/jasmine/jasmine.js:1001:15)
        at [object Object].next_ (http://localhost:88/backbone/WebClient-Backbone2/test/lib/jasmine/jasmine.js:1790:31)
        at [object Object].start (http://localhost:88/backbone/WebClient-Backbone2/test/lib/jasmine/jasmine.js:1743:8)
        at [object Object].execute (http://localhost:88/backbone/WebClient-Backbone2/test/lib/jasmine/jasmine.js:2070:14)
        at [object Object].next_ (http://localhost:88/backbone/WebClient-Backbone2/test/lib/jasmine/jasmine.js:1790:31)
        at [object Object].start (http://localhost:88/backbone/WebClient-Backbone2/test/lib/jasmine/jasmine.js:1743:8)
        at [object Object].execute (http://localhost:88/backbone/WebClient-Backbone2/test/lib/jasmine/jasmine.js:2215:14)
        at [object Object].next_ (http://localhost:88/backbone/WebClient-Backbone2/test/lib/jasmine/jasmine.js:1790:31)     
  • 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-05-27T15:17:33+00:00Added an answer on May 27, 2026 at 3:17 pm

    As mentioned in the comments, I found out that, this is due to the “new” in the model definition.

    So, after changing,

        var Photo = new Backbone.Model.extend({
    

    to

        var Photo = Backbone.Model.extend({
    

    The error disappeared.

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

Sidebar

Related Questions

I have been trying to learn how to add testing to existing code --
I am taking over someone elses code. What are some good ways to learn
Trying to learn pointer math better I wrote this code. The intention was to
Trying to learn a bit about PDO and is going through this tutorial .
I´m trying to learn C#, coming from a Python/PHP background, and I´m trying to
I'm trying to learn RegEx in Ruby, based on what I'm reading in The
I'm trying to learn C++ so forgive me if this question demonstrates a lack
Currently, I'm trying to learn Javascript by writing my code in Gedit then attempting
I was trying learn lex and yacc using the oreilly book. I tried following
Trying to learn some F# and I've run into a couple of hangups. Here's

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.