mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[tests/harness] require lodash before using it
This commit is contained in:
parent
ebb705cd89
commit
58c8e15db8
1 changed files with 33 additions and 24 deletions
|
@ -14,27 +14,6 @@
|
|||
var COVERAGE = window.COVERAGE = !!(/coverage/i.test(window.location.search));
|
||||
var DISABLE_RESIZE_CHECKER = window.DISABLE_RESIZE_CHECKER = true;
|
||||
|
||||
mocha.ui = _.wrap(mocha.ui, function (mochaUi, ui) {
|
||||
var ret = mochaUi.call(this, ui);
|
||||
|
||||
var _desc = window.describe;
|
||||
window.describe = wrap(window, 'describe', unwindDescribeArrays);
|
||||
window.describe.only = wrap(_desc, 'only', unwindDescribeArrays);
|
||||
function unwindDescribeArrays(describe, name, body) {
|
||||
if (!body && name && name instanceof Array) {
|
||||
body = name[1]; name = name[0];
|
||||
}
|
||||
|
||||
return describe.call(this, name, body);
|
||||
}
|
||||
});
|
||||
|
||||
mocha.setup({
|
||||
ui: 'bdd',
|
||||
timeout: 5000,
|
||||
reporter: 'html'
|
||||
});
|
||||
|
||||
require.config({
|
||||
baseUrl: '/',
|
||||
paths: {
|
||||
|
@ -75,6 +54,38 @@
|
|||
urlArgs: COVERAGE ? 'instrument=true' : void 0
|
||||
});
|
||||
|
||||
function setupMocha() {
|
||||
require(['lodash'], function (_) {
|
||||
|
||||
mocha.ui = _.wrap(mocha.ui, function (mochaUi, ui) {
|
||||
var ret = mochaUi.call(this, ui);
|
||||
|
||||
var oldDescribe = window.describe;
|
||||
window.describe = _.wrap(oldDescribe, unwindDescribeArrays);
|
||||
window.describe.only = _.wrap(oldDescribe.only, unwindDescribeArrays);
|
||||
function unwindDescribeArrays(fn, name, body) {
|
||||
if (!body && name && name instanceof Array) {
|
||||
body = name[1]; name = name[0];
|
||||
}
|
||||
|
||||
return fn.call(this, name, body);
|
||||
}
|
||||
|
||||
return ret;
|
||||
});
|
||||
|
||||
mocha.setup({
|
||||
ui: 'bdd',
|
||||
timeout: 5000,
|
||||
reporter: 'html'
|
||||
});
|
||||
|
||||
if (COVERAGE) setupCoverage(runTests);
|
||||
else runTests();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function setupCoverage(done) {
|
||||
document.title = document.title.replace('Tests', 'Coverage');
|
||||
require([
|
||||
|
@ -149,9 +160,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
if (COVERAGE) setupCoverage(runTests);
|
||||
else runTests();
|
||||
setupMocha();
|
||||
|
||||
})();</script>
|
||||
</head>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue