diff --git a/test/unit/index.html b/test/unit/index.html index 822a39bf5908a..f5ac1be523206 100644 --- a/test/unit/index.html +++ b/test/unit/index.html @@ -77,7 +77,12 @@ require([ 'kibana', 'sinon/sinon', - 'angular', + 'angular' + ], loadSpecs); + } + + function loadSpecs(kibana, sinon) { + require([ 'specs/apps/discover/hit_sort_fn', 'specs/apps/discover/directives/table', 'specs/apps/discover/directives/discover_field', @@ -153,49 +158,52 @@ 'specs/visualize/_create_raw_data', 'specs/visualize/_array_to_linked_list', 'specs/visualize/_collect_branch' - ], function (kibana, sinon) { - kibana.load(function () { - var xhr = sinon.useFakeXMLHttpRequest(); - - window.mochaRunner = mocha.run().on('end', function () { - window.mochaResults = this.stats; - window.mochaResults.details = getFailedTests(this); - xhr.restore(); - }); - - function getFailedTests(runner) { - var fails = []; - var suiteStack = []; - - (function recurse(suite) { - suiteStack.push(suite); - - (suite.tests || []) - .filter(function (test) { - return test.state !== 'passed' && test.state !== 'pending'; - }) - .forEach(function (test) { - fails.push({ - title: suiteStack.concat(test).reduce(function (title, suite) { - if (suite.title) { - return (title ? title + ' ' : '') + suite.title; - } else { - return title; - } - }, ''), - err: test.err ? (test.err.stack || test.err.message) : 'unknown error' - }); - }); + ], function () { + bootstrap(kibana, sinon); + }); + } - (suite.suites || []).forEach(recurse); + function bootstrap(kibana, sinon) { + kibana.load(function () { + var xhr = sinon.useFakeXMLHttpRequest(); - suiteStack.pop(); - }(runner.suite)); + window.mochaRunner = mocha.run().on('end', function () { + window.mochaResults = this.stats; + window.mochaResults.details = getFailedTests(this); + xhr.restore(); + }); - return fails; - } + function getFailedTests(runner) { + var fails = []; + var suiteStack = []; + + (function recurse(suite) { + suiteStack.push(suite); + + (suite.tests || []) + .filter(function (test) { + return test.state !== 'passed' && test.state !== 'pending'; + }) + .forEach(function (test) { + fails.push({ + title: suiteStack.concat(test).reduce(function (title, suite) { + if (suite.title) { + return (title ? title + ' ' : '') + suite.title; + } else { + return title; + } + }, ''), + err: test.err ? (test.err.stack || test.err.message) : 'unknown error' + }); + }); - }); + (suite.suites || []).forEach(recurse); + + suiteStack.pop(); + }(runner.suite)); + + return fails; + } }); }