UNPKG

spectacular

Version:

Advanced BDD framework for CoffeeScript and JavaScript

1,039 lines (933 loc) 30.2 kB
// Generated by CoffeeScript 1.6.3 var BADGE_MAP, CHAR_MAP, COLOR_MAP, Plurals, a, addClass, ancestors, breakPointTablet, buildHTML, currentWindowOnload, defaults, displayErrors, errors, escapeHTML, fixNodeHeight, hasClass, hasErrors, icon, k, params, removeClass, selfAndAncestors, stripHTML, tag, toggleClass, utils, v, viewerSize, wrapNode, _ref, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; spectacular.formatters.browser = {}; spectacular.widgets = {}; _ref = spectacular.formatters, CHAR_MAP = _ref.CHAR_MAP, COLOR_MAP = _ref.COLOR_MAP, BADGE_MAP = _ref.BADGE_MAP; utils = spectacular.utils; escapeHTML = function(str) { return str.replace(/</g, '&lt;').replace(/>/g, '&gt;'); }; stripHTML = function(str) { var n; n = document.createElement('span'); n.innerHTML = str; return n.textContent; }; selfAndAncestors = function(node, block) { block.call(this, node); return ancestors(node, block); }; ancestors = function(node, block) { var parent; parent = node.parentNode; if (hasClass(parent, 'example-group')) { block.call(this, parent); return ancestors(parent, block); } }; wrapNode = function(node) { if (node == null) { return []; } if (node.length != null) { return node; } else { return [node]; } }; hasClass = function(nl, cls) { nl = wrapNode(nl); return Array.prototype.every.call(nl, function(n) { return RegExp("(\\s|^)" + cls + "(\\s|$)").test(n.className); }); }; addClass = function(nl, cls) { nl = wrapNode(nl); return Array.prototype.forEach.call(nl, function(node) { if (!hasClass(node, cls)) { return node.className += " " + cls; } }); }; removeClass = function(nl, cls) { nl = wrapNode(nl); return Array.prototype.forEach.call(nl, function(node) { return node.className = node.className.replace(cls, ''); }); }; toggleClass = function(nl, cls) { nl = wrapNode(nl); return Array.prototype.forEach.call(nl, function(node) { if (hasClass(node, cls)) { return removeClass(node, cls); } else { return addClass(node, cls); } }); }; fixNodeHeight = function(nl) { nl = wrapNode(nl); return Array.prototype.forEach.call(nl, function(node) { return node.style.height = "" + node.clientHeight + "px"; }); }; tag = function(tag, inner, attrs, block) { var k, node, v, _ref1, _ref2; if (inner == null) { inner = ''; } if (attrs == null) { attrs = {}; } if (typeof inner === 'object') { _ref1 = ['', inner, attrs], inner = _ref1[0], attrs = _ref1[1], block = _ref1[2]; } if (typeof inner === 'function') { _ref2 = ['', {}, inner], inner = _ref2[0], attrs = _ref2[1], block = _ref2[2]; } if (typeof block === 'function') { inner = block(); } node = document.createElement(tag); for (k in attrs) { v = attrs[k]; node.setAttribute(k, v); } if (typeof inner === 'string') { node.innerHTML = inner; } else { node.appendChild(inner); } return node; }; buildHTML = function(html) { var res; res = tag('div', html).children; if (res.length === 1) { return res[0]; } else { return res; } }; icon = function(icon) { return tag('i', { "class": "icon-" + icon }); }; spectacular.widgets.ExampleViewer = (function() { function ExampleViewer() {} ExampleViewer.prototype.init = function(runner, reporter) { this.runner = runner; this.reporter = reporter; this.container = buildHTML(spectacular.templates.viewer()); this.view = this.container.querySelector('div'); this.expand = this.container.querySelector('button'); this.reporter.container.appendChild(this.container); return this.expand.onclick = function() { return toggleClass(document.querySelector('body'), 'view-expanded'); }; }; ExampleViewer.prototype.displayCard = function(example) { var _this = this; this.view.innerHTML = this.getCard(example); if (!hasClass(this.container, 'card-visible')) { addClass(this.container, 'card-visible'); } this.stack = this.view.querySelector('.stack'); this.expectationMessage = this.view.querySelector('.expectation-message'); this.expectations = this.view.querySelectorAll('.expectation'); if (this.expectations.length > 0) { return this.each(this.expectations, function(node, i) { var expectation, index; index = node.attributes['data-expectation'].value; expectation = example.result.expectations[index]; node.onclick = function() { return _this.displayExpectationDetails(node, expectation); }; if (i === 0) { return _this.displayExpectationDetails(node, expectation); } }); } else { if (example.result.expectations.length === 0 && example.examplePromise.reason) { return this.displayStack(example.examplePromise.reason.stack); } } }; ExampleViewer.prototype.displayExpectationDetails = function(node, expectation) { this.each(this.expectations, function(el) { return removeClass(el, 'active'); }); this.expectationMessage.innerHTML = expectation.message; this.expectationMessage.setAttribute('class', expectation.success ? 'expectation-message success' : 'expectation-message failure'); this.clearStack(); if (expectation.trace != null) { this.displayStack(expectation.trace.stack); } return addClass(node, 'active'); }; ExampleViewer.prototype.clearStack = function() { return this.stack.innerHTML = ''; }; ExampleViewer.prototype.displayStack = function(stack) { var parser, _this = this; parser = new spectacular.errors.ErrorParser(stack); return parser.lines.forEach(function(stackLine, i) { var column, div, file, line, method, _ref1; _ref1 = parser.details(stackLine), file = _ref1.file, line = _ref1.line, column = _ref1.column, method = _ref1.method; div = tag('div', function() { return tag('a', escapeHTML(stackLine)); }); div.onclick = function() { if (hasClass(div, 'has-source')) { return _this.hideSource(div); } else { return _this.displayLineSource(div, file, line, column); } }; _this.stack.appendChild(div); if (i === 0) { return _this.displayLineSource(div, file, line, column); } }); }; ExampleViewer.prototype.hideSource = function(div) { div.removeChild(div.children[1]); return removeClass(div, 'has-source'); }; ExampleViewer.prototype.displayLineSource = function(div, file, line, column) { var f, w; f = new spectacular.formatters.console.ErrorSourceFormatter(this.runner.options, file, line, column); w = function(s, c) { return "<span class='" + c + "'>" + s + "</span>"; }; return f.format().then(function(result) { div.appendChild(tag('pre', function() { var lines; lines = result.replace(/^\n|\n$/g, '').split('\n'); lines = lines.map(function(line) { line = line.replace(/^\s+(\d+\s)*\|/gm, w('$&', 'line-number')); return tag('span', line).outerHTML; }); return lines.join('\n'); })); return addClass(div, 'has-source'); }); }; ExampleViewer.prototype.each = function(nodes, block) { return Array.prototype.forEach.call(nodes, block); }; ExampleViewer.prototype.getCard = function(example) { return spectacular.templates.card({ example: example }); }; ExampleViewer.prototype.onStart = function(event) {}; ExampleViewer.prototype.onResult = function(event) {}; ExampleViewer.prototype.onEnd = function(event) {}; return ExampleViewer; })(); spectacular.widgets.ExamplesList = (function() { function ExamplesList() {} ExamplesList.prototype.init = function(runner, reporter) { var body, btn, openLeft, openRight, _this = this; this.runner = runner; this.reporter = reporter; this.examples = []; this.container = buildHTML(spectacular.templates.list({ chars: CHAR_MAP })); this.list = this.container.querySelector('div'); this.totalValue = this.container.querySelector('.all .total'); this.allValue = this.container.querySelector('.all .value'); this.viewer = this.reporter.widgets.filter(function(w) { return w.constructor === spectacular.widgets.ExampleViewer; })[0]; btn = this.container.querySelector('.btn-collapse'); btn.onclick = function() { toggleClass(_this.container, 'collapse'); if (hasClass(_this.container, 'collapse')) { return Array.prototype.forEach.call(_this.list.children, function(el) { return addClass(el, 'collapse'); }); } else { return Array.prototype.forEach.call(_this.list.children, function(el) { return removeClass(el, 'collapse'); }); } }; body = document.body; openLeft = this.container.querySelector('.btn-open-left'); openLeft.onclick = function() { if (hasClass(body, 'snapjs-left')) { return _this.reporter.snapper.close(); } else { return _this.reporter.snapper.open('left'); } }; openRight = this.container.querySelector('.btn-open-right'); openRight.onclick = function() { if (hasClass(body, 'snapjs-right')) { return _this.reporter.snapper.close(); } else { return _this.reporter.snapper.open('right'); } }; return this.reporter.container.appendChild(this.container); }; ExamplesList.prototype.onStart = function() { return this.totalValue.textContent = this.runner.examples.length; }; ExamplesList.prototype.onResult = function(event) { var example, state, _ref1; example = event.target; state = example.result.state; if ((state === 'failure' || state === 'errored') && !hasClass(this.reporter.container, 'hide-success')) { addClass(this.container, 'fail'); if ((_ref1 = this.viewer) != null) { _ref1.displayCard(example); } this.reporter.errorOccured(); } this.buildExample(example); this.examples.push(example); return this.allValue.textContent = this.examples.length; }; ExamplesList.prototype.onEnd = function(event) { if (hasClass(this.container, 'fail')) { return addClass(this.container, 'failure'); } else { return addClass(this.container, 'success'); } }; ExamplesList.prototype.buildExample = function(example) { var node; node = this.getParent(example); if (example.failed) { selfAndAncestors(node, function(node) { if (hasClass(node, 'success')) { removeClass(node, 'success'); return addClass(node, 'failure'); } }); } return node.appendChild(this.getExample(example)); }; ExamplesList.prototype.selectExample = function(example, node) { var previous; previous = this.list.querySelector('.active'); if (previous != null) { removeClass(previous, 'active'); } addClass(node, 'active'); this.viewer.displayCard(example); return this.reporter.openDetails(); }; ExamplesList.prototype.getExample = function(example) { var node, state, _this = this; state = example.result.state; node = tag('article', example.ownDescriptionWithExpectations, { "class": "example " + state, id: this.examples.length, title: example.fullDescription, 'data-index': stripHTML(example.fullDescription.toLowerCase()) }); node.onclick = function() { return _this.selectExample(_this.examples[node.attributes.id.value], node); }; return node; }; ExamplesList.prototype.getParent = function(example) { var a, ancestor, elders, id, n, node, parent, reversed, _i, _j, _len, _len1; elders = example.ancestors; elders.pop(); reversed = []; for (_i = 0, _len = elders.length; _i < _len; _i++) { a = elders[_i]; reversed.unshift(a); } node = this.list; n = 0; for (_j = 0, _len1 = reversed.length; _j < _len1; _j++) { ancestor = reversed[_j]; id = ancestor.ownDescription.replace(/^[\s\W]+|[\s\W]+$/g, '').replace(/[^\w\d]+/g, '-').toLowerCase(); if (id === '') { continue; } parent = node; node = node.querySelector("#" + id); if (node == null) { node = this.buildParent(ancestor, id, n); parent.appendChild(node); } n++; } return node; }; ExamplesList.prototype.buildParent = function(ancestor, id, n) { var content, header, index, node; content = "<header title='" + ancestor.description + "'>\n" + ancestor.ownDescription + "\n</header>"; index = ancestor.allExamples.map(function(ex) { return stripHTML(ex.description.toLowerCase()); }).join(); node = tag('section', content, { id: id, "class": "example-group " + (ancestor.failed ? 'failure' : 'success') + " level" + n, 'data-index': index }); header = node.querySelector('header'); header.onclick = function() { return toggleClass(node, 'collapse'); }; return node; }; return ExamplesList; })(); spectacular.widgets.ExamplesSearch = (function() { function ExamplesSearch() {} ExamplesSearch.prototype.init = function(runner, reporter) { var _ref1, _this = this; this.runner = runner; this.reporter = reporter; this.container = buildHTML(spectacular.templates.search()); this.form = this.container.querySelector('form'); this.input = this.container.querySelector('input'); this.style = this.container.querySelector('style'); if ((_ref1 = this.reporter.container.querySelector('#examples header')) != null) { _ref1.appendChild(this.container); } return this.form.onsubmit = function() { var e, value; try { value = spectacular.utils.strip(_this.input.value); if (value === '') { _this.style.innerHTML = ''; } else { _this.style.innerHTML = "[data-index]:not([data-index*=\"" + (value.toLowerCase()) + "\"]) { display: none; }"; } } catch (_error) { e = _error; console.log(e); console.log(e.stack); } return false; }; }; ExamplesSearch.prototype.onStart = function(e) {}; ExamplesSearch.prototype.onResult = function(e) {}; ExamplesSearch.prototype.onEnd = function(e) {}; return ExamplesSearch; })(); Plurals = { failure: 'failures', errored: 'errored', skipped: 'skipped', pending: 'pending', success: 'success' }; spectacular.widgets.RunnerProgress = (function() { function RunnerProgress() {} RunnerProgress.prototype.init = function(runner, reporter) { var state; this.runner = runner; this.reporter = reporter; this.container = buildHTML(spectacular.templates.progress({ seed: this.runner.options.seed, chars: CHAR_MAP })); this.totalValue = this.container.querySelector('.all .total'); this.timeValue = this.container.querySelector('.time .value'); this.allValue = this.container.querySelector('.all .value'); for (state in CHAR_MAP) { this[state + 'Value'] = this.container.querySelector("." + state + " .value"); this[state + 'Text'] = this.container.querySelector("." + state + " .symbol"); } return this.reporter.container.appendChild(this.container); }; RunnerProgress.prototype.onStart = function() { var btn, self, state, _results, _this = this; this.counters = { all: 0, failure: 0, errored: 0, skipped: 0, pending: 0, success: 0 }; this.totalValue.textContent = this.runner.examples.length; this.interval = setInterval(function() { var t; t = new Date(new Date() - _this.runner.specsStartedAt); return _this.timeValue.textContent = "" + (t.getSeconds()) + "." + (t.getMilliseconds()) + "s"; }, 100); self = this; _results = []; for (state in CHAR_MAP) { btn = this.container.querySelector("." + state); _results.push(btn.onclick = function() { return toggleClass(document.body, "hide-" + this.attributes['data-state'].value); }); } return _results; }; RunnerProgress.prototype.update = function() { var c, key, _results; this.allValue.textContent = this.counters.all; _results = []; for (key in CHAR_MAP) { c = CHAR_MAP[key]; this["" + key + "Value"].textContent = this.counters[key]; this["" + key + "Text"].textContent = ' ' + (this.counters[key] > 1 ? Plurals[key] : key); if (this.counters[key] && !hasClass(this[key], 'not-zero')) { _results.push(addClass(this[key], 'not-zero')); } else { _results.push(void 0); } } return _results; }; RunnerProgress.prototype.onResult = function(e) { var example, _ref1; example = e.target; this.counters.all++; this.counters[example.result.state]++; if ((_ref1 = example.result.state) === 'failure' || _ref1 === 'errored') { addClass(this.container, 'fail'); } return this.update(); }; RunnerProgress.prototype.onEnd = function(e) { var results, t; clearInterval(this.interval); results = e.target; t = new Date(results.specsEndedAt - results.specsStartedAt); this.timeValue.textContent = "" + (t.getSeconds()) + "." + (t.getMilliseconds()) + "s"; if (this.counters.failure === 0 && this.counters.errored === 0) { return addClass(this.container, 'success'); } else { return addClass(this.container, 'failure'); } }; return RunnerProgress; })(); breakPointTablet = 1024; spectacular.BrowserReporter = (function() { function BrowserReporter(runner, widgets) { this.runner = runner; this.widgets = widgets; this.onEnd = __bind(this.onEnd, this); this.onResult = __bind(this.onResult, this); this.onStart = __bind(this.onStart, this); this.options = this.runner.options; this.registerEvents(); } BrowserReporter.prototype.registerEvents = function() { this.runner.on('start', this.onStart); this.runner.on('result', this.onResult); return this.runner.on('end', this.onEnd); }; BrowserReporter.prototype.unregisterEvents = function() { this.runner.off('start', this.onStart); this.runner.off('result', this.onResult); return this.runner.off('end', this.onEnd); }; BrowserReporter.prototype.init = function() { var _this = this; this.container = tag('div', { id: 'container' }); document.body.appendChild(this.container); this.widgets.forEach(function(w) { return w.init(_this.runner, _this); }); return this.initSnapper(); }; BrowserReporter.prototype.initSnapper = function() { var previousOnResize, _this = this; this.snapper = new Snap({ element: this.container.querySelector('#examples'), minPosition: -viewerSize() }); if (window.innerWidth < breakPointTablet) { this.container.querySelector('#viewer').setAttribute('style', "width: " + (viewerSize()) + "px;"); this.snapper.open('left'); } else { this.snapper.disable(); } previousOnResize = document.body.onresize; return document.body.onresize = function(e) { if (typeof previousOnResize === "function") { previousOnResize(e); } return _this.onResize(e); }; }; BrowserReporter.prototype.errorOccured = function() { addClass(document.querySelector('body'), 'hide-success'); return this.openDetails(); }; BrowserReporter.prototype.openDetails = function() { if (window.innerWidth < breakPointTablet) { return this.snapper.open('right'); } }; BrowserReporter.prototype.onResize = function() { if (window.innerWidth < breakPointTablet) { this.snapper.enable(); this.snapper.close(); this.snapper.settings({ minPosition: -viewerSize() }); return this.container.querySelector('#viewer').setAttribute('style', "width: " + (viewerSize()) + "px;"); } else { this.container.querySelector('#viewer').setAttribute('style', ''); this.snapper.close(); return this.snapper.disable(); } }; BrowserReporter.prototype.onStart = function(e) { var _this = this; return this.widgets.forEach(function(w) { return w.onStart(e); }); }; BrowserReporter.prototype.onResult = function(e) { return this.widgets.forEach(function(w) { return w.onResult(e); }); }; BrowserReporter.prototype.onEnd = function(e) { return this.widgets.forEach(function(w) { return w.onEnd(e); }); }; return BrowserReporter; })(); spectacular.BrowserMethods = function(options) { var cache, loaders; cache = {}; loaders = {}; if (options.valueOutput == null) { options.valueOutput = function(value) { return "<span class='value'>" + (options.htmlSafe(String(value))) + "</span>"; }; } if (options.htmlSafe == null) { options.htmlSafe = function(str) { return str.replace(/</g, '&lt;').replace(/>/g, '&gt;'); }; } if (options.loadFile == null) { options.loadFile = function(file) { var failure, promise, req, success; promise = new spectacular.Promise; success = function(data) { return promise.resolve(data); }; failure = function(reason) { return promise.reject(reason); }; if (file in cache) { setTimeout((function() { return success(cache[file]); }), 0); return promise; } if (file in loaders) { loaders[file].push({ success: success, failure: failure }); return promise; } req = new XMLHttpRequest(); req.onload = function() { var data; data = this.responseText; cache[file] = data; if (req.status >= 400) { return loaders[file].forEach(function(f) { return f.failure(new Error(data)); }); } else { return loaders[file].forEach(function(f) { return f.success(data); }); } }; loaders[file] = [ { success: success, failure: failure } ]; req.open('get', file, true); req.send(); return promise; }; } if (options.getOriginalSourceFor == null) { options.getOriginalSourceFor = function(file, line, column) { var fileSource, promise, _this = this; promise = new spectacular.Promise; fileSource = null; this.loadFile(this.getSourceURLFor(file)).then(function(source) { fileSource = source; return _this.loadFile(_this.getSourceMapURLFor(file)); }).then(function(sourceMap) { var consumer, _ref1; consumer = new window.sourceMap.SourceMapConsumer(sourceMap); _ref1 = consumer.originalPositionFor({ line: line, column: column }), line = _ref1.line, column = _ref1.column; return promise.resolve({ content: fileSource, line: line, column: column }); }).fail(function() { return _this.loadFile(file).then(function(content) { return promise.resolve({ content: content, line: line, column: column }); }); }); return promise; }; } if (options.hasSourceMap == null) { options.hasSourceMap = function(file) { return false; }; } if (options.getSourceURLFor == null) { options.getSourceURLFor = function(file) {}; } if (options.getSourceMapURLFor == null) { return options.getSourceMapURLFor = function(file) {}; } }; spectacular.URLParameters = (function() { function URLParameters(parameters) { var tuples, _this = this; tuples = String(parameters).split('&').map(function(tuple) { return tuple.split('='); }); tuples.forEach(function(_arg) { var key, value; key = _arg[0], value = _arg[1]; return _this.consumeKeys(_this, _this.parseKey(key), _this.parseValue(value)); }); } URLParameters.prototype.parseKey = function(key) { if (key.substr(-1) === ']') { key = key.slice(0, -1); } return key.split(/\]*\[/g); }; URLParameters.prototype.parseValue = function(value) { switch (true) { case this.isBoolean(value): return /true|on|yes/.test(value); case this.isFloat(value): return parseFloat(value); case this.isInteger(value): return parseInt(value); default: return value; } }; URLParameters.prototype.isBoolean = function(value) { return /^(true|false|on|off|yes|no)$/.test(String(value)); }; URLParameters.prototype.isFloat = function(value) { return /^\d+\.\d+$/.test(String(value)); }; URLParameters.prototype.isInteger = function(value) { return /^\d+$/.test(String(value)); }; URLParameters.prototype.isArray = function(a) { return Object.prototype.toString.call(a) === '[object Array]'; }; URLParameters.prototype.consumeKeys = function(target, keys, value) { var previousKey, targets, _this = this; previousKey = null; targets = [this]; return keys.forEach(function(key, index) { var keysRemains, o; keysRemains = keys.length - index > 1; if (_this.isInteger(key)) { if (target[key] != null) { if (keysRemains) { target = target[key]; } else { target[key].push(value); } } else { if (keysRemains) { o = {}; target[key] = o; target = o; } else { target[key] = [value]; } } } else if (key === '') { target = targets[targets.length - 2]; if (_this.isArray(target[previousKey])) { if (keysRemains) { target = targets[previousKey]; } else { target[previousKey].push(value); } } else { if (keysRemains) { target = target[previousKey] = []; } else { target[previousKey] = [value]; } } } else { if (target[key] != null) { if (keysRemains) { target = target[key]; } else { target[key] = value; } } else { if (keysRemains) { target = target[key] = {}; } else { target[key] = value; } } } targets.push(target); return previousKey = key; }); }; return URLParameters; })(); spectacular.paths = spectacular.paths || []; spectacular.options = spectacular.options || {}; defaults = { coffee: false, verbose: false, profile: false, trace: true, longTrace: false, showSource: true, format: 'progress', matchersRoot: './specs/support/matchers', helpersRoot: './specs/support/helpers', fixturesRoot: './specs/support/fixtures', noMatchers: false, noHelpers: false, colors: true, random: true, seed: null, server: false, globs: [] }; for (k in defaults) { v = defaults[k]; if (!k in spectacular.options) { spectacular.options[k] = v; } } a = document.createElement('a'); a.href = window.location; if (a.search && a.search.length > 1) { params = new spectacular.URLParameters(decodeURI(a.search.slice(1))); } for (k in params) { v = params[k]; if (params.hasOwnProperty(k)) { spectacular.options[k] = v; } } spectacular.BrowserMethods(spectacular.options); spectacular.env = new spectacular.Environment(spectacular.options); spectacular.env.globalize(); spectacular.env.runner.loadStartedAt = new Date(); viewerSize = function() { return Math.min(document.body.clientWidth - 60, 500); }; window.env = spectacular.env; displayErrors = function(msg, file, line) { var formatter; formatter = new spectacular.formatters.console.ErrorSourceFormatter(spectacular.options, file, line); return formatter.format().then(function(src) { var node; node = document.createElement('div'); node.innerHTML = spectacular.templates.error({ message: msg, source: src }); return document.body.appendChild(node); }); }; hasErrors = false; errors = []; window.onerror = function(e) { hasErrors = true; displayErrors.apply(null, arguments); return true; }; currentWindowOnload = window.onload; window.onload = function() { var filter, n, reporter, s, scripts, _i, _len, _ref1; if (currentWindowOnload != null) { currentWindowOnload(); } if (hasErrors) { return; } utils = spectacular.utils; if (spectacular.options.verbose) { console.log(utils.indent(utils.inspect(spectacular.options))); console.log(utils.indent(utils.inspect(spectacular.paths))); console.log('\n Scripts loaded:'); scripts = document.querySelectorAll('script[src]'); for (_i = 0, _len = scripts.length; _i < _len; _i++) { s = scripts[_i]; console.log(" " + ((_ref1 = s.attributes.getNamedItem("src")) != null ? _ref1.value : void 0)); } console.log(''); } reporter = new spectacular.BrowserReporter(spectacular.env.runner, [new spectacular.widgets.RunnerProgress, new spectacular.widgets.ExamplesList, new spectacular.widgets.ExampleViewer, new spectacular.widgets.ExamplesSearch]); if (spectacular.options.filter) { filter = spectacular.options.filter; n = document.createElement('div'); if (spectacular.options.verbose) { console.log("Example Filter: '" + filter + "'"); } spectacular.env.rootExampleGroup.allExamples.forEach(function(example) { var desc; n.innerHTML = example.description; desc = n.textContent; if (desc.indexOf(filter) !== -1) { return example.exclusive = true; } }); } reporter.init(); spectacular.env.runner.loadEndedAt = new Date(); spectacular.env.runner.specsStartedAt = new Date(); return spectacular.env.run().fail(function(reason) { return console.log(reason.stack); }); };