Support generators in tests via coMocha, instead of custom code
* coMocha offers better error stack trace
This commit is contained in:
parent
14bf3184bb
commit
289b049377
5 changed files with 6 additions and 14 deletions
|
@ -184,19 +184,7 @@ mocha.setup({
|
|||
grep: ZoteroUnit.grep
|
||||
});
|
||||
|
||||
// Enable Bluebird generator support in Mocha
|
||||
(function () {
|
||||
var Runnable = Mocha.Runnable;
|
||||
var run = Runnable.prototype.run;
|
||||
Runnable.prototype.run = function (fn) {
|
||||
if (this.fn.constructor.name === 'GeneratorFunction') {
|
||||
this.fn = Zotero.Promise.coroutine(this.fn);
|
||||
} else if (typeof this.fn == 'function' && this.fn.isGenerator()) {
|
||||
throw new Error("Attempting to use a legacy generator in Mocha test");
|
||||
}
|
||||
return run.call(this, fn);
|
||||
};
|
||||
})();
|
||||
coMocha(Mocha);
|
||||
|
||||
before(function () {
|
||||
// Store all prefs set in runtests.sh
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue