Note that there are some explanatory texts on larger screens.

plurals
  1. POTesting backbone-relational with jasmine
    text
    copied!<p><strong>UPDATED:</strong></p> <p>I have a simple Backbone-relational model:</p> <pre><code>@App.M.Product = Backbone.RelationalModel.extend defaults: {} url: App.D.dataURL relations: [ { type: Backbone.HasMany key: 'templates' relatedModel: 'App.M.Template' collectionType: 'App.C.Templates' reverseRelation: key: 'product' } { type: Backbone.HasMany key: 'pages' relatedModel: 'App.M.Page' collectionType: 'App.C.Pages' reverseRelation: key: 'product' } { type: Backbone.HasMany key: 'uploaded_images' relatedModel: 'App.M.UploadedImage' collectionType: 'App.C.UploadedImages' reverseRelation: key: 'product' } ] initialize: -&gt; if @get('minimumNumberOfPages') &lt; 1 @set 'minimumNumberOfPages', 1 fixPages: -&gt; col = @get 'pages' col.each (page) -&gt; page.collection = col </code></pre> <p>and an even simplier test suite:</p> <pre><code>"use strict" describe 'Product', -&gt; pr = null beforeEach -&gt; pr = new App.M.Product it 'should be defined', -&gt; expect(pr).toBeDefined() </code></pre> <p>However, the model fails to initialize (taken from testem's terminal output):</p> <pre><code>TypeError: Cannot read property 'prototype' of undefined at Backbone.HasMany.Backbone.Relation.extend.initialize (http://localhost:7357/app/bower_components/backbone-relational/backbone-relational.js:835:78) at Backbone.Relation (http://localhost:7357/app/bower_components/backbone-relational/backbone-relational.js:537:9) at new child (http://localhost:7357/app/bower_components/backbone/backbone-min.js:1:25220) at _.extend.initializeRelation (http://localhost:7357/app/bower_components/backbone-relational/backbone-relational.js:137:5) at null.&lt;anonymous&gt; (http://localhost:7357/app/bower_components/backbone-relational/backbone-relational.js:1176:31) at Array.forEach (native) at Function.w.each.w.forEach (http://localhost:7357/app/bower_components/underscore/underscore-min.js:1:599) at Backbone.RelationalModel.Backbone.Model.extend.initializeRelations (http://localhost:7357/app/bower_components/backbone-relational/backbone-relational.js:1175:6) at Backbone.RelationalModel.Backbone.Model.extend.set (http://localhost:7357/app/bower_components/backbone-relational/backbone-relational.js:1373:11) at Backbone.Model (http://localhost:7357/app/bower_components/backbone/backbone-min.js:1:3929) </code></pre> <p>Why is that? The app is wokring correctly, the tests are not.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload