mirror of
https://github.com/elastic/kibana.git
synced 2025-04-20 07:48:52 -04:00
* [eslint] update eslint config to 0.3.0 * [eslint] autofix * [fixtures/hits] reformat to comply with max-len lint rule * [eslint] enable no-var and autofix * [eslint] enable prefer-const and autofix * [eslint] fix autofix-incompatible no-var and prefer-const violations * [eslint] enable quotes+no-extra-semi and autofix
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
const sinon = require('sinon');
|
|
const autoRelease = require('auto-release-sinon');
|
|
|
|
require('babel/register')(require('../src/optimize/babel_options').node);
|
|
|
|
// hook into the global afterEach variable to allow autoReleaseSinon to register
|
|
// an afterEach handler before mocha has exposed itself to the test files.
|
|
//
|
|
// This works by telling autoReleaseSinon to use a fake "afterEach" function.
|
|
// Rather than actually record an afterEach handler the function tracks all of
|
|
// the calls it received and queues them up in queuedAfterEachArgs.
|
|
//
|
|
// The global "afterEach" variable is also tracked, and once it is assigned by mocha
|
|
// the variable global is reconfigured to point directly to the new value (from mocha)
|
|
// and all of the queued invocations are executed.
|
|
const queuedAfterEachArgs = [];
|
|
Object.defineProperty(global, 'afterEach', {
|
|
configurable: true,
|
|
get() { return undefined; },
|
|
set(afterEach) {
|
|
Object.defineProperty(global, 'afterEach', {
|
|
configurable: true,
|
|
writable: true,
|
|
value: afterEach
|
|
});
|
|
|
|
queuedAfterEachArgs.forEach(function (args) {
|
|
afterEach.apply(null, args);
|
|
});
|
|
|
|
return global.afterEach;
|
|
}
|
|
});
|
|
|
|
autoRelease.setupAutoRelease(sinon, function () {
|
|
if (!global.afterEach) {
|
|
queuedAfterEachArgs.push(Array.prototype.slice.call(arguments));
|
|
} else {
|
|
global.afterEach.apply(this, arguments);
|
|
}
|
|
});
|