2 * Jasmine 2.0 standalone `boot.js` modified for Karma.
3 * This file is registered in `index.js`. This version
4 * does not include `HtmlReporter` setup.
9 * Require Jasmine's core files. Specifically, this requires and
10 * attaches all of Jasmine's code to the `jasmine` reference.
12 window.jasmine = jasmineRequire.core(jasmineRequire);
16 * Create the Jasmine environment. This is used to run all specs
19 var env = jasmine.getEnv();
21 var focusedSuites = [];
22 var focusedSpecs = [];
23 var insideFocusedSuite = false;
25 var focuseSpec = function(env, description, body) {
26 var spec = env.it(description, body);
27 focusedSpecs.push(spec.id);
31 var focuseSuite = function(env, description, body) {
32 if (insideFocusedSuite) {
33 return env.describe(description, body);
36 insideFocusedSuite = true;
37 var suite = env.describe(description, body);
38 insideFocusedSuite = false
39 focusedSuites.push(suite.id);
44 * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require
47 window.setTimeout = window.setTimeout;
48 window.setInterval = window.setInterval;
49 window.clearTimeout = window.clearTimeout;
50 window.clearInterval = window.clearInterval;
54 * Build up the functions that will be exposed as the Jasmine
57 var jasmineInterface = {
58 describe: function(description, specDefinitions) {
59 return env.describe(description, specDefinitions);
62 xdescribe: function(description, specDefinitions) {
63 return env.xdescribe(description, specDefinitions);
66 ddescribe: function(description, specDefinitions) {
67 return focuseSuite(env, description, specDefinitions);
70 it: function(desc, func) {
71 return env.it(desc, func);
74 xit: function(desc, func) {
75 return env.xit(desc, func);
78 iit: function(desc, func) {
79 return focuseSpec(env, desc, func);
82 beforeEach: function(beforeEachFunction) {
83 return env.beforeEach(beforeEachFunction);
86 afterEach: function(afterEachFunction) {
87 return env.afterEach(afterEachFunction);
90 expect: function(actual) {
91 return env.expect(actual);
98 spyOn: function(obj, methodName) {
99 return env.spyOn(obj, methodName);
102 jsApiReporter: new jasmine.JsApiReporter({
103 timer: new jasmine.Timer()
109 * Add all of the Jasmine global/public interface to the proper
110 * global, so a project can use the public interface directly.
111 * For example, calling `describe` in specs instead of
112 * `jasmine.getEnv().describe`.
114 for (var property in jasmineInterface) {
115 if (jasmineInterface.hasOwnProperty(property)) {
116 window[property] = jasmineInterface[property];
120 env.executeFiltered = function() {
121 if (focusedSpecs.length) {
122 env.execute(focusedSpecs);
123 } else if (focusedSuites.length) {
124 env.execute(focusedSuites);
132 * Expose the interface for adding custom equality testers.
134 jasmine.addCustomEqualityTester = function(tester) {
135 env.addCustomEqualityTester(tester);
140 * Expose the interface for adding custom expectation matchers
142 jasmine.addMatchers = function(matchers) {
143 return env.addMatchers(matchers);
148 * Expose the mock interface for the JavaScript timeout functions
150 jasmine.clock = function() {