Custom boot
If you want to customize your jasmine environment you can customize your boot.js file. The core of |
(function() {
window.jasmine = jasmineRequire.core(jasmineRequire);
jasmineRequire.html(jasmine);
var env = jasmine.getEnv();
|
Customizing the interfaceOnce the core jasmine interface has been loaded, you can add new functions or rewrite existing functions. |
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
Here, we're adding some aliases so |
jasmineInterface.before = jasmineInterface.beforeEach;
|
|
jasmineInterface.after = jasmineInterface.afterEach;
|
and |
jasmineInterface.context = jasmineInterface.describe;
if (typeof window == "undefined" && typeof exports == "object") {
extend(exports, jasmineInterface);
} else {
extend(window, jasmineInterface);
}
|
Adding a custom reporterYou can also add your own reporter either in addition to or in place of the |
env.addReporter(jasmineInterface.jsApiReporter);
|
You can also customize how specs are filtered from the current run by changing the Alternately, specs to be run may also be specified after the tests have been parsed by passing an array of suite or spec IDs to the execute function. These IDs can be gleaned by traversing the tree of parsed tests accessible via env.topSuite(). |
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam("spec"); }
});
env.specFilter = function(spec) {
return specFilter.matches(spec.getFullName());
};
window.setTimeout = window.setTimeout;
window.setInterval = window.setInterval;
window.clearTimeout = window.clearTimeout;
window.clearInterval = window.clearInterval;
|
By default, Jasmine will begin execution when the |
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
env.execute(env.topSuite().id);
};
|
Helper function to add the Jasmine public interface to the correct object. |
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}
}());
|