mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
* add prettierignore * switch to eslint:recommended + eslint-config-prettier * fix eslint violations * remove more .jshintrc files * better conditional structure * add prettier and update prettier ignore * add precommit hook to run prettier * add lint check to precommit and format check to ci * format all the things * add generated files * let npm do it's thing with package.json
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
module.exports = function addAsyncTestSuites(fn) {
|
|
// Trick mocha into running the before hook without any tests.
|
|
var runner = it("").parent;
|
|
var originalDescribe = global.describe;
|
|
|
|
before(function() {
|
|
// Test init can take a while. (This does not change the timeout of the actual tests, just the lasso compile time).
|
|
this.timeout(20000);
|
|
|
|
// Remove empty test inserted above.
|
|
runner.tests.splice(0, 1);
|
|
|
|
// patch describe to add to the current suite
|
|
var patchedDescribe = (global.describe = function(name, fn) {
|
|
return moveSuite(originalDescribe(name, fn), runner);
|
|
});
|
|
patchedDescribe.only = function(name, fn) {
|
|
return moveSuite(originalDescribe.only(name, fn), runner);
|
|
};
|
|
patchedDescribe.skip = function(name, fn) {
|
|
return moveSuite(originalDescribe.skip(name, fn), runner);
|
|
};
|
|
|
|
return fn();
|
|
});
|
|
|
|
after(function() {
|
|
// restore the previous describe
|
|
global.describe = originalDescribe;
|
|
});
|
|
};
|
|
|
|
function moveSuite(suite, newParent) {
|
|
var oldSuites = suite.parent.suites;
|
|
newParent.addSuite(suite);
|
|
oldSuites.splice(oldSuites.indexOf(suite), 1);
|
|
return suite;
|
|
}
|