From cfd7cb3287e42368251927fa588850f15dc936d3 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 4 Oct 2019 12:45:21 +0100 Subject: [PATCH] This is to work around https://github.com/chaijs/chai/issues/1298 Fundamentally we cannot pull in chai and add plugins to it without being careful of the order of those plugins as it's a singleton. All we're really interested in is the `expect` function to just get the preconfigured one from the interface tests. --- package.json | 6 ++---- test/cli/bitswap.js | 2 +- test/cli/block.js | 2 +- test/cli/bootstrap.js | 2 +- test/cli/commands.js | 2 +- test/cli/config.js | 5 +---- test/cli/daemon.js | 2 +- test/cli/dag.js | 2 +- test/cli/dht.js | 6 +----- test/cli/dns.js | 2 +- test/cli/file.js | 2 +- test/cli/files.js | 2 +- test/cli/general.js | 2 +- test/cli/id.js | 5 +---- test/cli/init.js | 2 +- test/cli/key.js | 2 +- test/cli/ls.js | 2 +- test/cli/name-pubsub.js | 5 +---- test/cli/object.js | 2 +- test/cli/parser.js | 5 +---- test/cli/pin.js | 2 +- test/cli/ping.js | 5 +---- test/cli/progress-bar.js | 2 +- test/cli/pubsub.js | 5 +---- test/cli/refs-local.js | 2 +- test/cli/refs.js | 2 +- test/cli/repo.js | 2 +- test/cli/swarm.js | 5 +---- test/cli/version.js | 2 +- test/core/bitswap.spec.js | 5 +---- test/core/block.spec.js | 5 +---- test/core/bootstrap.spec.js | 6 +----- test/core/circuit-relay.js | 6 +----- test/core/config.spec.js | 6 +----- test/core/create-node.spec.js | 5 +---- test/core/dag.spec.js | 6 +----- test/core/dht.spec.js | 6 +----- test/core/exports.spec.js | 5 +---- test/core/files-regular-utils.js | 5 +---- test/core/files-sharding.spec.js | 5 +---- test/core/files.spec.js | 5 +---- test/core/gc-lock.spec.js | 6 +----- test/core/gc.spec.js | 6 +----- test/core/init.spec.js | 5 +---- test/core/kad-dht.node.js | 5 +---- test/core/key-exchange.js | 5 +---- test/core/libp2p.spec.js | 6 +----- test/core/mfs-preload.spec.js | 6 +----- test/core/name-pubsub.js | 6 +----- test/core/name.spec.js | 5 +---- test/core/object.spec.js | 5 +---- test/core/pin-set.js | 6 +----- test/core/pin.js | 6 +----- test/core/pin.spec.js | 6 +----- test/core/ping.spec.js | 6 ++---- test/core/preload.spec.js | 5 +---- test/core/pubsub.spec.js | 6 +----- test/core/stats.spec.js | 6 +----- test/core/swarm.spec.js | 6 +----- test/core/utils.js | 6 +----- test/gateway/index.js | 5 +---- test/http-api/inject/bitswap.js | 2 +- test/http-api/inject/block.js | 2 +- test/http-api/inject/bootstrap.js | 2 +- test/http-api/inject/config.js | 2 +- test/http-api/inject/dag.js | 5 +---- test/http-api/inject/dht.js | 5 +---- test/http-api/inject/dns.js | 2 +- test/http-api/inject/files.js | 2 +- test/http-api/inject/id.js | 2 +- test/http-api/inject/name.js | 6 +----- test/http-api/inject/object.js | 6 +----- test/http-api/inject/pin.js | 2 +- test/http-api/inject/ping.js | 6 +----- test/http-api/inject/pubsub.js | 5 +---- test/http-api/inject/resolve.js | 2 +- test/http-api/inject/version.js | 2 +- test/http-api/routes.js | 3 --- test/utils/ipfs-exec.js | 3 --- 79 files changed, 79 insertions(+), 245 deletions(-) diff --git a/package.json b/package.json index d908183deb..742c2eb9b9 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "ipfs-bitswap": "^0.26.0", "ipfs-block": "~0.8.1", "ipfs-block-service": "~0.16.0", - "ipfs-http-client": "^38.0.0", + "ipfs-http-client": "^38.0.1", "ipfs-http-response": "~0.3.1", "ipfs-mfs": "^0.13.0", "ipfs-multipart": "^0.2.0", @@ -195,16 +195,14 @@ "devDependencies": { "aegir": "^20.3.1", "base64url": "^3.0.1", - "chai": "^4.2.0", "clear-module": "^4.0.0", "delay": "^4.1.0", "detect-node": "^2.0.4", "dir-compare": "^1.7.3", - "dirty-chai": "^2.0.1", "execa": "^2.0.4", "form-data": "^2.5.1", "hat": "0.0.3", - "interface-ipfs-core": "^0.115.1", + "interface-ipfs-core": "^0.115.3", "ipfs-interop": "~0.1.0", "ipfsd-ctl": "^0.47.2", "libp2p-websocket-star": "~0.10.2", diff --git a/test/cli/bitswap.js b/test/cli/bitswap.js index cac76152b3..c22cefe81c 100644 --- a/test/cli/bitswap.js +++ b/test/cli/bitswap.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOn = require('../utils/on-and-off').on const PeerId = require('peer-id') const CID = require('cids') diff --git a/test/cli/block.js b/test/cli/block.js index c00e06caf7..ee0d47b86f 100644 --- a/test/cli/block.js +++ b/test/cli/block.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') describe('block', () => runOnAndOff((thing) => { diff --git a/test/cli/bootstrap.js b/test/cli/bootstrap.js index 262f80e97e..3d5f0f6562 100644 --- a/test/cli/bootstrap.js +++ b/test/cli/bootstrap.js @@ -2,7 +2,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') describe('bootstrap', () => runOnAndOff((thing) => { diff --git a/test/cli/commands.js b/test/cli/commands.js index e445892a72..fc186a11ac 100644 --- a/test/cli/commands.js +++ b/test/cli/commands.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') const commandCount = 95 diff --git a/test/cli/config.js b/test/cli/config.js index 0a8158e65e..a90df0468b 100644 --- a/test/cli/config.js +++ b/test/cli/config.js @@ -1,10 +1,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const fs = require('fs') const path = require('path') const runOnAndOff = require('../utils/on-and-off') diff --git a/test/cli/daemon.js b/test/cli/daemon.js index 1be77940d6..0bee3e507e 100644 --- a/test/cli/daemon.js +++ b/test/cli/daemon.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const clean = require('../utils/clean') const ipfsCmd = require('../utils/ipfs-exec') const isWindows = require('../utils/platforms').isWindows diff --git a/test/cli/dag.js b/test/cli/dag.js index f4094777eb..8fbad2e458 100644 --- a/test/cli/dag.js +++ b/test/cli/dag.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') const path = require('path') diff --git a/test/cli/dht.js b/test/cli/dht.js index 3e066ac270..71b2012155 100644 --- a/test/cli/dht.js +++ b/test/cli/dht.js @@ -2,11 +2,7 @@ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const path = require('path') const DaemonFactory = require('ipfsd-ctl') const df = DaemonFactory.create({ diff --git a/test/cli/dns.js b/test/cli/dns.js index 93e4610e3b..34722404ad 100644 --- a/test/cli/dns.js +++ b/test/cli/dns.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') const isIPFS = require('is-ipfs') diff --git a/test/cli/file.js b/test/cli/file.js index f7852c89ef..86a15d499d 100644 --- a/test/cli/file.js +++ b/test/cli/file.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') const file = 'QmR56UJmAaZLXLdTT1ALrE9vVqV8soUEekm9BMd4FnuYqV' const dir = 'Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z' diff --git a/test/cli/files.js b/test/cli/files.js index 62c3139b0c..868fdd1f36 100644 --- a/test/cli/files.js +++ b/test/cli/files.js @@ -3,7 +3,7 @@ const fs = require('fs') const os = require('os') -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const path = require('path') const hat = require('hat') const compareDir = require('dir-compare').compareSync diff --git a/test/cli/general.js b/test/cli/general.js index ee26a51e67..4bff0d095d 100644 --- a/test/cli/general.js +++ b/test/cli/general.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') describe('general cli options', () => runOnAndOff.off((thing) => { diff --git a/test/cli/id.js b/test/cli/id.js index b3f6102003..3498d0d240 100644 --- a/test/cli/id.js +++ b/test/cli/id.js @@ -2,12 +2,9 @@ 'use strict' const sinon = require('sinon') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const YargsPromise = require('yargs-promise') const clearModule = require('clear-module') -chai.use(dirtyChai) describe('id', () => { let cli diff --git a/test/cli/init.js b/test/cli/init.js index 897936c07a..234d5b4c39 100644 --- a/test/cli/init.js +++ b/test/cli/init.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const path = require('path') const fs = require('fs') const clean = require('../utils/clean') diff --git a/test/cli/key.js b/test/cli/key.js index d75f88bf0b..90b5992421 100644 --- a/test/cli/key.js +++ b/test/cli/key.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') const hat = require('hat') diff --git a/test/cli/ls.js b/test/cli/ls.js index d86c17490b..bd5870c6fa 100644 --- a/test/cli/ls.js +++ b/test/cli/ls.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') const delay = require('delay') diff --git a/test/cli/name-pubsub.js b/test/cli/name-pubsub.js index f3e1126039..af899501d2 100644 --- a/test/cli/name-pubsub.js +++ b/test/cli/name-pubsub.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const path = require('path') const ipfsExec = require('../utils/ipfs-exec') diff --git a/test/cli/object.js b/test/cli/object.js index d653e2fb82..7ccdb856f9 100644 --- a/test/cli/object.js +++ b/test/cli/object.js @@ -3,7 +3,7 @@ 'use strict' const hat = require('hat') -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') const UnixFs = require('ipfs-unixfs') const path = require('path') diff --git a/test/cli/parser.js b/test/cli/parser.js index 660def1f60..3352f16fcb 100644 --- a/test/cli/parser.js +++ b/test/cli/parser.js @@ -1,10 +1,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const parser = require('../../src/cli/parser') const YargsPromise = require('yargs-promise') diff --git a/test/cli/pin.js b/test/cli/pin.js index d8aa5e23c6..20a777be92 100644 --- a/test/cli/pin.js +++ b/test/cli/pin.js @@ -2,7 +2,7 @@ /* eslint max-nested-callbacks: ["error", 8] */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const CID = require('cids') const runOnAndOff = require('../utils/on-and-off') const path = require('path') diff --git a/test/cli/ping.js b/test/cli/ping.js index 6d843bc113..66216fe0d2 100644 --- a/test/cli/ping.js +++ b/test/cli/ping.js @@ -2,8 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') +const { expect } = require('interface-ipfs-core/src/utils/mocha') const DaemonFactory = require('ipfsd-ctl') const ipfsExec = require('../utils/ipfs-exec') const path = require('path') @@ -11,8 +10,6 @@ const df = DaemonFactory.create({ type: 'js', IpfsClient: require('ipfs-http-client') }) -const expect = chai.expect -chai.use(dirtyChai) const config = { Bootstrap: [], diff --git a/test/cli/progress-bar.js b/test/cli/progress-bar.js index 21708a59f8..353222a2a2 100644 --- a/test/cli/progress-bar.js +++ b/test/cli/progress-bar.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const createProgressBar = require('../../src/cli/utils').createProgressBar describe('progress bar', () => { diff --git a/test/cli/pubsub.js b/test/cli/pubsub.js index 017b665ce1..5255946ee1 100644 --- a/test/cli/pubsub.js +++ b/test/cli/pubsub.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const delay = require('delay') const series = require('async/series') const ipfsExec = require('../utils/ipfs-exec') diff --git a/test/cli/refs-local.js b/test/cli/refs-local.js index 0232c3a9d3..6b1e5fc872 100644 --- a/test/cli/refs-local.js +++ b/test/cli/refs-local.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') describe('refs-local', () => runOnAndOff((thing) => { diff --git a/test/cli/refs.js b/test/cli/refs.js index bd7704d400..e102dfd067 100644 --- a/test/cli/refs.js +++ b/test/cli/refs.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const runOnAndOff = require('../utils/on-and-off') // Note: There are more comprehensive tests in interface-js-ipfs-core diff --git a/test/cli/repo.js b/test/cli/repo.js index f47437f67f..f5e47d7eb7 100644 --- a/test/cli/repo.js +++ b/test/cli/repo.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const repoVersion = require('ipfs-repo').repoVersion const runOnAndOff = require('../utils/on-and-off') diff --git a/test/cli/swarm.js b/test/cli/swarm.js index 2fca1d2899..0ec1b1b00b 100644 --- a/test/cli/swarm.js +++ b/test/cli/swarm.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const sinon = require('sinon') const ipfsExec = require('../utils/ipfs-exec') const path = require('path') diff --git a/test/cli/version.js b/test/cli/version.js index 67fe53a295..4aa053ccad 100644 --- a/test/cli/version.js +++ b/test/cli/version.js @@ -3,7 +3,7 @@ 'use strict' const os = require('os') -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const repoVersion = require('ipfs-repo').repoVersion const pkgversion = require('../../package.json').version const runOnAndOff = require('../utils/on-and-off') diff --git a/test/core/bitswap.spec.js b/test/core/bitswap.spec.js index eaa368b7a2..deee69150e 100644 --- a/test/core/bitswap.spec.js +++ b/test/core/bitswap.spec.js @@ -3,10 +3,7 @@ 'use strict' const hat = require('hat') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const _ = require('lodash') const series = require('async/series') const waterfall = require('async/waterfall') diff --git a/test/core/block.spec.js b/test/core/block.spec.js index c4c54bc3b3..68d11fc66d 100644 --- a/test/core/block.spec.js +++ b/test/core/block.spec.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const hat = require('hat') const IPFSFactory = require('ipfsd-ctl') diff --git a/test/core/bootstrap.spec.js b/test/core/bootstrap.spec.js index e8928b0e9b..566ffa3b7e 100644 --- a/test/core/bootstrap.spec.js +++ b/test/core/bootstrap.spec.js @@ -1,11 +1,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const isNode = require('detect-node') const IPFS = require('../../src') diff --git a/test/core/circuit-relay.js b/test/core/circuit-relay.js index 628544e520..751f382bd3 100644 --- a/test/core/circuit-relay.js +++ b/test/core/circuit-relay.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const waterfall = require('async/waterfall') const multiaddr = require('multiaddr') const crypto = require('crypto') diff --git a/test/core/config.spec.js b/test/core/config.spec.js index f884f74348..bd5fa43814 100644 --- a/test/core/config.spec.js +++ b/test/core/config.spec.js @@ -1,11 +1,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const config = require('../../src/core/config') describe('config', () => { diff --git a/test/core/create-node.spec.js b/test/core/create-node.spec.js index 8c7d2a88a6..7d77fc7ded 100644 --- a/test/core/create-node.spec.js +++ b/test/core/create-node.spec.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const series = require('async/series') const sinon = require('sinon') const waterfall = require('async/waterfall') diff --git a/test/core/dag.spec.js b/test/core/dag.spec.js index b5dc5b1fbf..a9c184a2cd 100644 --- a/test/core/dag.spec.js +++ b/test/core/dag.spec.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const IPFSFactory = require('ipfsd-ctl') const IPFS = require('../../src/core') diff --git a/test/core/dht.spec.js b/test/core/dht.spec.js index 5ce711473a..d8fde46d18 100644 --- a/test/core/dht.spec.js +++ b/test/core/dht.spec.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const isNode = require('detect-node') const IPFSFactory = require('ipfsd-ctl') diff --git a/test/core/exports.spec.js b/test/core/exports.spec.js index 4506dd8251..306dca99a7 100644 --- a/test/core/exports.spec.js +++ b/test/core/exports.spec.js @@ -11,10 +11,7 @@ const multihashing = require('multihashing-async') const multicodec = require('multicodec') const PeerId = require('peer-id') const PeerInfo = require('peer-info') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const Ipfs = require('../../') diff --git a/test/core/files-regular-utils.js b/test/core/files-regular-utils.js index 4cad233e4c..d8520cf583 100644 --- a/test/core/files-regular-utils.js +++ b/test/core/files-regular-utils.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const utils = require('../../src/core/components/files-regular/utils') describe('files-regular/utils', () => { diff --git a/test/core/files-sharding.spec.js b/test/core/files-sharding.spec.js index 6abcd86823..2d82834f7f 100644 --- a/test/core/files-sharding.spec.js +++ b/test/core/files-sharding.spec.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const pull = require('pull-stream') const IPFS = require('../../src/core') diff --git a/test/core/files.spec.js b/test/core/files.spec.js index 5c59e0d4db..b620306c17 100644 --- a/test/core/files.spec.js +++ b/test/core/files.spec.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const hat = require('hat') const pull = require('pull-stream') const IPFSFactory = require('ipfsd-ctl') diff --git a/test/core/gc-lock.spec.js b/test/core/gc-lock.spec.js index 3effa1325e..30410204fb 100644 --- a/test/core/gc-lock.spec.js +++ b/test/core/gc-lock.spec.js @@ -1,11 +1,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const delay = require('delay') const parallel = require('async/parallel') const pull = require('pull-stream') diff --git a/test/core/gc.spec.js b/test/core/gc.spec.js index cc4b3be910..42022f3fed 100644 --- a/test/core/gc.spec.js +++ b/test/core/gc.spec.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const IPFSFactory = require('ipfsd-ctl') const pEvent = require('p-event') const env = require('ipfs-utils/src/env') diff --git a/test/core/init.spec.js b/test/core/init.spec.js index 5a9c893839..182438cef7 100644 --- a/test/core/init.spec.js +++ b/test/core/init.spec.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const isNode = require('detect-node') const hat = require('hat') const IPFS = require('../../src/core') diff --git a/test/core/kad-dht.node.js b/test/core/kad-dht.node.js index 032df5289a..4722ec66e2 100644 --- a/test/core/kad-dht.node.js +++ b/test/core/kad-dht.node.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const path = require('path') const parallel = require('async/parallel') diff --git a/test/core/key-exchange.js b/test/core/key-exchange.js index bb114dcd0d..47910edb71 100644 --- a/test/core/key-exchange.js +++ b/test/core/key-exchange.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const hat = require('hat') const IPFS = require('../../src/core') diff --git a/test/core/libp2p.spec.js b/test/core/libp2p.spec.js index ec52c0bd0e..f159db7a02 100644 --- a/test/core/libp2p.spec.js +++ b/test/core/libp2p.spec.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const MemoryStore = require('interface-datastore').MemoryDatastore const PeerInfo = require('peer-info') const PeerBook = require('peer-book') diff --git a/test/core/mfs-preload.spec.js b/test/core/mfs-preload.spec.js index 3c066472cf..3fb84cfa00 100644 --- a/test/core/mfs-preload.spec.js +++ b/test/core/mfs-preload.spec.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const delay = require('delay') const waitFor = require('../utils/wait-for') const mfsPreload = require('../../src/core/mfs-preload') diff --git a/test/core/name-pubsub.js b/test/core/name-pubsub.js index 09d940c4af..0e5fdd59ad 100644 --- a/test/core/name-pubsub.js +++ b/test/core/name-pubsub.js @@ -3,11 +3,7 @@ 'use strict' const hat = require('hat') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const base64url = require('base64url') const { fromB58String } = require('multihashes') const peerId = require('peer-id') diff --git a/test/core/name.spec.js b/test/core/name.spec.js index 458cfb1278..d517707c9e 100644 --- a/test/core/name.spec.js +++ b/test/core/name.spec.js @@ -3,10 +3,7 @@ 'use strict' const hat = require('hat') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const sinon = require('sinon') const parallel = require('async/parallel') diff --git a/test/core/object.spec.js b/test/core/object.spec.js index 789b32af8a..0cafe32f98 100644 --- a/test/core/object.spec.js +++ b/test/core/object.spec.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const hat = require('hat') const IPFSFactory = require('ipfsd-ctl') const auto = require('async/auto') diff --git a/test/core/pin-set.js b/test/core/pin-set.js index cf1b0263bf..6a77025c26 100644 --- a/test/core/pin-set.js +++ b/test/core/pin-set.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const parallelLimit = require('async/parallelLimit') const series = require('async/series') const { diff --git a/test/core/pin.js b/test/core/pin.js index fd67c25936..d5e096ad3a 100644 --- a/test/core/pin.js +++ b/test/core/pin.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const fs = require('fs') const { diff --git a/test/core/pin.spec.js b/test/core/pin.spec.js index 467593dc03..9d55f24aa0 100644 --- a/test/core/pin.spec.js +++ b/test/core/pin.spec.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const IPFSFactory = require('ipfsd-ctl') const IPFS = require('../../src/core') diff --git a/test/core/ping.spec.js b/test/core/ping.spec.js index 05163a6b5e..e6227503ce 100644 --- a/test/core/ping.spec.js +++ b/test/core/ping.spec.js @@ -1,16 +1,14 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') +const { expect } = require('interface-ipfs-core/src/utils/mocha') const pull = require('pull-stream/pull') const drain = require('pull-stream/sinks/drain') const parallel = require('async/parallel') const DaemonFactory = require('ipfsd-ctl') const isNode = require('detect-node') const path = require('path') -const expect = chai.expect -chai.use(dirtyChai) + const df = DaemonFactory.create({ exec: path.resolve(`${__dirname}/../../src/cli/bin.js`), IpfsClient: require('ipfs-http-client') diff --git a/test/core/preload.spec.js b/test/core/preload.spec.js index e40c0a740f..318c179e02 100644 --- a/test/core/preload.spec.js +++ b/test/core/preload.spec.js @@ -5,10 +5,7 @@ const hat = require('hat') const parallel = require('async/parallel') const waterfall = require('async/waterfall') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const pull = require('pull-stream') const CID = require('cids') diff --git a/test/core/pubsub.spec.js b/test/core/pubsub.spec.js index a341d787d7..1fc46623bc 100644 --- a/test/core/pubsub.spec.js +++ b/test/core/pubsub.spec.js @@ -3,11 +3,7 @@ 'use strict' const hat = require('hat') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const IPFS = require('../../src') const createTempRepo = require('../utils/create-repo-nodejs') diff --git a/test/core/stats.spec.js b/test/core/stats.spec.js index 3771a0b2ce..e522720aa7 100644 --- a/test/core/stats.spec.js +++ b/test/core/stats.spec.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const pull = require('pull-stream') const IPFSFactory = require('ipfsd-ctl') const IPFS = require('../../src/core') diff --git a/test/core/swarm.spec.js b/test/core/swarm.spec.js index 7002ec3edd..40c2d23ee8 100644 --- a/test/core/swarm.spec.js +++ b/test/core/swarm.spec.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const IPFSFactory = require('ipfsd-ctl') const IPFS = require('../../src/core') diff --git a/test/core/utils.js b/test/core/utils.js index e0c620608a..a4d00e329f 100644 --- a/test/core/utils.js +++ b/test/core/utils.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const fs = require('fs') const fromB58String = require('multihashes').fromB58String diff --git a/test/gateway/index.js b/test/gateway/index.js index 48ecd7dcff..a9b640d89b 100644 --- a/test/gateway/index.js +++ b/test/gateway/index.js @@ -2,10 +2,7 @@ /* eslint dot-notation: 0, dot-notation: 0, quote-props: 0 */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const Daemon = require('../../src/cli/daemon') const loadFixture = require('aegir/fixtures') const os = require('os') diff --git a/test/http-api/inject/bitswap.js b/test/http-api/inject/bitswap.js index 44c265267e..e5c1fe09a3 100644 --- a/test/http-api/inject/bitswap.js +++ b/test/http-api/inject/bitswap.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const CID = require('cids') const waitFor = require('../../utils/wait-for') diff --git a/test/http-api/inject/block.js b/test/http-api/inject/block.js index e247dc9225..794893ea3a 100644 --- a/test/http-api/inject/block.js +++ b/test/http-api/inject/block.js @@ -2,7 +2,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const fs = require('fs') const FormData = require('form-data') const streamToPromise = require('stream-to-promise') diff --git a/test/http-api/inject/bootstrap.js b/test/http-api/inject/bootstrap.js index 713c6be08c..8e59ab89d0 100644 --- a/test/http-api/inject/bootstrap.js +++ b/test/http-api/inject/bootstrap.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const qs = require('qs') const defaultList = require('../../../src/core/runtime/config-nodejs.js')().Bootstrap diff --git a/test/http-api/inject/config.js b/test/http-api/inject/config.js index f361037569..852a65a0d9 100644 --- a/test/http-api/inject/config.js +++ b/test/http-api/inject/config.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const fs = require('fs') const FormData = require('form-data') const streamToPromise = require('stream-to-promise') diff --git a/test/http-api/inject/dag.js b/test/http-api/inject/dag.js index d2507b6fc7..1e3996d582 100644 --- a/test/http-api/inject/dag.js +++ b/test/http-api/inject/dag.js @@ -3,10 +3,7 @@ 'use strict' const hat = require('hat') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const DAGNode = require('ipld-dag-pb').DAGNode const Readable = require('stream').Readable const FormData = require('form-data') diff --git a/test/http-api/inject/dht.js b/test/http-api/inject/dht.js index f844658417..039df2bee2 100644 --- a/test/http-api/inject/dht.js +++ b/test/http-api/inject/dht.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') module.exports = (http) => { // TODO: unskip when DHT is enabled: https://github.com/ipfs/js-ipfs/pull/1994 diff --git a/test/http-api/inject/dns.js b/test/http-api/inject/dns.js index c5b4c705ae..0e01879e54 100644 --- a/test/http-api/inject/dns.js +++ b/test/http-api/inject/dns.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') module.exports = (http) => { describe('/dns', () => { diff --git a/test/http-api/inject/files.js b/test/http-api/inject/files.js index 7c1c0b6a48..ee015a217c 100644 --- a/test/http-api/inject/files.js +++ b/test/http-api/inject/files.js @@ -3,7 +3,7 @@ 'use strict' const crypto = require('crypto') -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const FormData = require('form-data') const streamToPromise = require('stream-to-promise') const multibase = require('multibase') diff --git a/test/http-api/inject/id.js b/test/http-api/inject/id.js index dec6c66aa9..4022535e70 100644 --- a/test/http-api/inject/id.js +++ b/test/http-api/inject/id.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') module.exports = (http) => { describe('/id', () => { diff --git a/test/http-api/inject/name.js b/test/http-api/inject/name.js index b181f2935a..2fbf56c499 100644 --- a/test/http-api/inject/name.js +++ b/test/http-api/inject/name.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') - -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') const checkAll = (bits) => string => bits.every(bit => string.includes(bit)) diff --git a/test/http-api/inject/object.js b/test/http-api/inject/object.js index 662474e0b0..77370b2620 100644 --- a/test/http-api/inject/object.js +++ b/test/http-api/inject/object.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) - +const { expect } = require('interface-ipfs-core/src/utils/mocha') const fs = require('fs') const FormData = require('form-data') const streamToPromise = require('stream-to-promise') diff --git a/test/http-api/inject/pin.js b/test/http-api/inject/pin.js index 50fafe1da2..bf22ecb259 100644 --- a/test/http-api/inject/pin.js +++ b/test/http-api/inject/pin.js @@ -2,7 +2,7 @@ /* eslint max-nested-callbacks: ["error", 8] */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const FormData = require('form-data') const streamToPromise = require('stream-to-promise') const multibase = require('multibase') diff --git a/test/http-api/inject/ping.js b/test/http-api/inject/ping.js index 4467a05d11..ca1429afe8 100644 --- a/test/http-api/inject/ping.js +++ b/test/http-api/inject/ping.js @@ -2,11 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') - -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') module.exports = (http) => { describe('/ping', function () { diff --git a/test/http-api/inject/pubsub.js b/test/http-api/inject/pubsub.js index ce1d803019..bb8198636b 100644 --- a/test/http-api/inject/pubsub.js +++ b/test/http-api/inject/pubsub.js @@ -2,10 +2,7 @@ /* eslint-env mocha */ 'use strict' -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) +const { expect } = require('interface-ipfs-core/src/utils/mocha') module.exports = (http) => { describe('/pubsub', () => { diff --git a/test/http-api/inject/resolve.js b/test/http-api/inject/resolve.js index c228a06607..e2f3f390e0 100644 --- a/test/http-api/inject/resolve.js +++ b/test/http-api/inject/resolve.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const FormData = require('form-data') const streamToPromise = require('stream-to-promise') diff --git a/test/http-api/inject/version.js b/test/http-api/inject/version.js index d1cb6a1577..fb6ec8f3ef 100644 --- a/test/http-api/inject/version.js +++ b/test/http-api/inject/version.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ 'use strict' -const expect = require('chai').expect +const { expect } = require('interface-ipfs-core/src/utils/mocha') const pkgversion = require('./../../../package.json').version module.exports = (http) => { diff --git a/test/http-api/routes.js b/test/http-api/routes.js index e0e3431b90..258b411800 100644 --- a/test/http-api/routes.js +++ b/test/http-api/routes.js @@ -2,9 +2,6 @@ 'use strict' const fs = require('fs') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -chai.use(dirtyChai) const hat = require('hat') const Daemon = require('../../src/cli/daemon') const promisify = require('promisify-es6') diff --git a/test/utils/ipfs-exec.js b/test/utils/ipfs-exec.js index ff657e034d..3e002722b3 100644 --- a/test/utils/ipfs-exec.js +++ b/test/utils/ipfs-exec.js @@ -1,9 +1,6 @@ 'use strict' const execa = require('execa') -const chai = require('chai') -const dirtyChai = require('dirty-chai') -chai.use(dirtyChai) const path = require('path') const _ = require('lodash')