diff --git a/test/content/runtests.js b/test/content/runtests.js index 7e7dc99fd..7992db997 100644 --- a/test/content/runtests.js +++ b/test/content/runtests.js @@ -66,6 +66,19 @@ function Reporter(runner) { // Setup Mocha mocha.setup({ui:"bdd", reporter:Reporter}); + +// 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); + } + return run.call(this, fn); + }; +})(); + var assert = chai.assert, expect = chai.expect; diff --git a/test/tests/support.js b/test/tests/support.js index a0be8eef2..da690c68f 100644 --- a/test/tests/support.js +++ b/test/tests/support.js @@ -1,6 +1,6 @@ describe("Support Functions for Unit Testing", function() { describe("resetDB", function() { - it("should restore the DB to factory settings", Zotero.Promise.coroutine(function* () { + it("should restore the DB to factory settings", function* () { this.timeout(30000); yield Zotero.Items.erase(1); assert.isFalse(yield Zotero.Items.getAsync(1)); @@ -9,6 +9,6 @@ describe("Support Functions for Unit Testing", function() { assert.isObject(item); yield item.loadItemData(); assert.equal(item.getField("url"), "https://www.zotero.org/support/quick_start_guide"); - })); + }); }); });