UNPKG

3.31 kBJavaScriptView Raw
1// This file is heavily based on jasmine-core\lib\jasmine-core\boot1.js
2(function () {
3 var env = jasmine.getEnv();
4
5 /**
6 * ## Runner Parameters
7 *
8 * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
9 */
10
11 var queryString = new jasmine.QueryString({
12 getWindowLocation: function () {
13 return window.location;
14 }
15 });
16
17 var specQueryParam = queryString.getParam('spec')
18 var filterSpecs = !!specQueryParam;
19
20 var config = {
21 stopOnSpecFailure: queryString.getParam('stopOnSpecFailure'),
22 stopSpecOnExpectationFailure: queryString.getParam(
23 'stopSpecOnExpectationFailure'
24 ),
25 hideDisabled: queryString.getParam('hideDisabled')
26 };
27
28 var random = queryString.getParam('random');
29
30 if (random !== undefined && random !== '') {
31 config.random = random;
32 }
33
34 var seed = queryString.getParam('seed');
35 if (seed) {
36 config.seed = seed;
37 }
38
39 /**
40 * ## Reporters
41 * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
42 */
43 var htmlReporter = new jasmine.HtmlReporter({
44 env: env,
45 navigateWithNewParam: function (key, value) {
46 return queryString.navigateWithNewParam(key, value);
47 },
48 addToExistingQueryString: function (key, value) {
49 return queryString.fullStringWithNewParam(key, value);
50 },
51 getContainer: function () {
52 return document.body;
53 },
54 createElement: function () {
55 return document.createElement.apply(document, arguments);
56 },
57 createTextNode: function () {
58 return document.createTextNode.apply(document, arguments);
59 },
60 timer: new jasmine.Timer(),
61 filterSpecs: filterSpecs
62 });
63
64 /**
65 * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
66 */
67 env.addReporter(jsApiReporter);
68 env.addReporter(htmlReporter);
69
70 /**
71 * Filter which specs will be run by matching the start of the full name against the `spec` query param.
72 * Don't override the specFilter unless the query param exists since it may be provided by external config.
73 */
74 var specQueryParam = queryString.getParam("spec")
75 if (specQueryParam) {
76 var specFilter = new jasmine.HtmlSpecFilter({
77 filterString: function () {
78 return specQueryParam;
79 }
80 });
81
82 config.specFilter = function (spec) {
83 return specFilter.matches(spec.getFullName());
84 };
85 }
86
87 env.configure(config);
88
89 /**
90 * ## Execution
91 *
92 * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
93 */
94 htmlReporter.initialize();
95})();