Comments (3)
As my understanding and guessing, you might explicitly load Backbone
library in some ways before require.config({}) call, for instance, loading
it via script tag, the easiest way.
But here you don't load Backbone as helper before generated
require.config({}) by this template.
Try load Backbone via helper as an attempting.
BTW, I found a defect of your module definition which directly access
Backbone from global context rather than module's dependencies list.
Should fix that problematic invoking.
On Friday, May 17, 2013, Stefan Vermaas wrote:
Hi,
I'm using this template to run my jasmine tests in the requireJS
framework. But while using this template I ran into an issue. I'm not
exactly sure or this has to do with the template, RequireJS or Jasmine, so
please say so if I'm in the wrong repo.In my main.js file ( where the configuration for my RequireJS application
lives ) I've defined some dependencies for my application. I "globalise"
jQuery, Backbone and Underscore, so I don't need to call them for the
second time in my modules.// main.js// Define the basic configurationrequire.config({
baseUrl: 'app/javascripts',
paths: {
jquery: 'vendor/jquery/jquery',
underscore: 'vendor/underscore-amd/underscore',
backbone: 'vendor/backbone-amd/backbone',
},
shim: {
'backbone': {
deps: ['jquery', 'underscore'],
exports: 'Backbone'
},
'underscore': {
exports: '_'
},
'jquery': {
exports: '$'
},
'app': {
deps: ['jquery', 'underscore', 'backbone' ]
}
}});
// Define the applicationrequire(['app'], function( app ) {
app.initialize();});This allows me to use jQuery, Backbone and Underscore in my separate
modules, like this:define([], function() {
var Model = Backbone.Model.extend({});
return Model;});But when I try this template for testing with Jasmine. I run into an
error. It tells me that Backbone isn't defined yet. But if I do include
Backbone in my module, the tests start working again.// base_view.js with Backbone etc defineddefine([
'jquery',
'underscore',
'backbone'], function( $, _, Backbone ) {});So what am I doing wrong? I can't figure it out..
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/25
.
from grunt-template-jasmine-requirejs.
So what you're basically saying is defining a module like this ( see example below ) and load Backbone etc in every module. Correct?
// base_view.js with Backbone etc defined
define([
'jquery',
'underscore',
'backbone'
], function( $, _, Backbone ) {
// Define the baseModel
var baseModel = Backbone.Model.extend();
return baseModel;
});
Because on this way, the tests will succeed. I thought it was OK to get the Backbone object grom the global context, but I guess it isn't?
from grunt-template-jasmine-requirejs.
@stefanvermaas how are you loading backbone in your grunt config? If you don't pre-load it explicitly then it won't be loaded at all until you call it as a dependency (which is what your example seems to show)
Do you ever need it as an AMD dependency? If not, then you can load it in the vendor definition so that it gets loaded separately.
from grunt-template-jasmine-requirejs.
Related Issues (20)
- Script load reorder option HOT 1
- Empty `context.outfile` HOT 1
- Some errors are not caught correctly HOT 2
- Wait for the dom to be ready HOT 1
- Relative protocol not supported
- no polyfills HOT 2
- Vendor script with UMD makes require complain HOT 2
- PR 65 has had some interesting side-effects HOT 1
- Stack overflow when spec files are in sub folder of .grunt without sub folders HOT 1
- when spec file is in .grunt/grunt-contrib-jasmine the link to require.js starts with a slash
- Script files seem to be in a different order now HOT 5
- src/templates/jasmine-requirejs.html styles needs to support less HOT 2
- Add polyfills back in template HOT 1
- Error when using with requirejs-text plugin HOT 3
- Backslash in script path HOT 1
- Integrated with jasmine-jquery HOT 1
- Does not support Lodash 3+ HOT 1
- PhantomJS timed out HOT 2
- require.js file now being written to project root HOT 2
- Building error on version 12.2.0 on-prem
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-template-jasmine-requirejs.