Last active
August 29, 2015 13:56
-
-
Save intel352/8900895 to your computer and use it in GitHub Desktop.
(WIP) Jasmine 2.0 boot.js for CommonJS
This file contains hidden or 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
// boot code for jasmine, require paths were customized for my env | |
// on my commonjs server, added boot.js as the main file of mod_jasmine, which is wrapping my copy of jasmine-core node package | |
var jasmineRequire = require('mod_jasmine/jasmine-core/lib/jasmine-core/jasmine.js'); | |
var jasmine = jasmineRequire.core(jasmineRequire); | |
var consoleFns = require('mod_jasmine/jasmine-core/lib/console/console.js'); | |
extend(jasmineRequire, consoleFns); | |
jasmineRequire.console(jasmineRequire, jasmine); | |
var env = jasmine.getEnv(); | |
var jasmineInterface = { | |
describe: function(description, specDefinitions) { | |
return env.describe(description, specDefinitions); | |
}, | |
xdescribe: function(description, specDefinitions) { | |
return env.xdescribe(description, specDefinitions); | |
}, | |
it: function(desc, func) { | |
return env.it(desc, func); | |
}, | |
xit: function(desc, func) { | |
return env.xit(desc, func); | |
}, | |
beforeEach: function(beforeEachFunction) { | |
return env.beforeEach(beforeEachFunction); | |
}, | |
afterEach: function(afterEachFunction) { | |
return env.afterEach(afterEachFunction); | |
}, | |
expect: function(actual) { | |
return env.expect(actual); | |
}, | |
spyOn: function(obj, methodName) { | |
return env.spyOn(obj, methodName); | |
}, | |
jsApiReporter: new jasmine.JsApiReporter({ | |
timer: new jasmine.Timer() | |
}) | |
}; | |
function extend(destination, source) { | |
for (var property in source) destination[property] = source[property]; | |
return destination; | |
} | |
jasmine.addCustomEqualityTester = function(tester) { | |
env.addCustomEqualityTester(tester); | |
}; | |
jasmine.addMatchers = function(matchers) { | |
return env.addMatchers(matchers); | |
}; | |
jasmine.clock = function() { | |
return env.clock; | |
}; | |
exports.jasmine = jasmine; | |
exports.jasmineInterface = jasmineInterface; | |
exports.extend = extend; |
This file contains hidden or 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
// the require("mod_jasmine") loads boot.js | |
var mj = require("mod_jasmine"), | |
jasmine = mj.jasmine; | |
// extending jasmineInterface funcs (describe(), it() ) onto global var | |
mj.extend(global, mj.jasmineInterface); | |
// load in specs | |
require("jasmine/spec/DeprecatedSpec.ds"); | |
require("jasmine/spec/PlayerSpec.ds"); | |
var jasmineEnv = jasmine.getEnv(), | |
consoleReporter = new jasmine.ConsoleReporter({ | |
print: function(str){output += str;}, | |
timer: new jasmine.Timer() | |
}); | |
// run tests | |
jasmineEnv.addReporter(consoleReporter); | |
jasmineEnv.execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment