-
-
Save bolshakov/12a314269302fae5e1c7af379a0db66d to your computer and use it in GitHub Desktop.
Jasmine and RequireJS together. Easy way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require ['fileA', 'fileB'], (A, B) -> | |
describe "An example", -> | |
it "depends on A and B" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Little snippet to make Jasmine and RequireJS play nice together. | |
* | |
* */ | |
(function(){ | |
var originalRequire = require; | |
var originalJasmineExecute = jasmine.getEnv().execute; | |
var requiresCounter = 0; | |
require = function (deps, callback){ | |
requiresCounter++; | |
var newCallback = function(){ | |
requiresCounter--; | |
callback.apply(this, Array.prototype.slice.call(arguments)); | |
if (requiresCounter === 0){ | |
// Trigger jasmine execution | |
originalJasmineExecute.call(jasmine.getEnv()); | |
} | |
} | |
originalRequire.call(this, deps, newCallback); | |
}; | |
jasmine.getEnv().execute = function(){}; | |
originalRequire.config({baseUrl : "http://localhost:8000/public/assets/"}); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment