From 77c8be96258831e2b398039499a0c06aa2103f38 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 4 Oct 2019 07:35:15 +0100 Subject: [PATCH] fix: configure chai for use by other modules Workaround for https://github.com/chaijs/chai/issues/1298 The order in which plugins are applied to chai is important and can break tests in other modules that run the tests from this one. --- package.json | 1 + src/key/rename.js | 7 +------ src/utils/mocha.js | 5 +++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index fd4d97cf..8e8eee80 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "bs58": "^4.0.1", "callbackify": "^1.1.0", "chai": "^4.2.0", + "chai-as-promised": "^7.1.1", "cids": "~0.7.1", "concat-stream": "^2.0.0", "delay": "^4.3.0", diff --git a/src/key/rename.js b/src/key/rename.js index ff3b5b16..b2c89561 100644 --- a/src/key/rename.js +++ b/src/key/rename.js @@ -2,13 +2,8 @@ /* eslint max-nested-callbacks: ["error", 6] */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') const hat = require('hat') -const { getDescribe, getIt } = require('../utils/mocha') - -const expect = chai.expect -chai.use(dirtyChai) +const { getDescribe, getIt, expect } = require('../utils/mocha') module.exports = (createCommon, options) => { const describe = getDescribe(options) diff --git a/src/utils/mocha.js b/src/utils/mocha.js index d9fe0fb6..2c5c1b95 100644 --- a/src/utils/mocha.js +++ b/src/utils/mocha.js @@ -2,9 +2,10 @@ 'use strict' const chai = require('chai') -const dirtyChai = require('dirty-chai') -chai.use(dirtyChai) +// Do not reorder these statements - https://github.com/chaijs/chai/issues/1298 +chai.use(require('chai-as-promised')) +chai.use(require('dirty-chai')) module.exports.expect = chai.expect