Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 6a7eb8a

Browse files
committed
fix: pull in preconfigured chai from interface tests
This is to work around chaijs/chai#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.
1 parent 55e64d4 commit 6a7eb8a

21 files changed

+20
-106
lines changed

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@
104104
"devDependencies": {
105105
"aegir": "^20.3.1",
106106
"browser-process-platform": "~0.1.1",
107-
"chai": "^4.2.0",
108-
"chai-as-promised": "^7.1.1",
109107
"cross-env": "^6.0.0",
110-
"dirty-chai": "^2.0.1",
111108
"go-ipfs-dep": "^0.4.22",
112109
"interface-ipfs-core": "^0.115.0",
113110
"ipfsd-ctl": "^0.47.1",

test/commands.spec.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const chai = require('chai')
5-
const dirtyChai = require('dirty-chai')
6-
const expect = chai.expect
7-
chai.use(dirtyChai)
8-
4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
95
const ipfsClient = require('../src')
10-
116
const f = require('./utils/factory')
127

138
describe('.commands', function () {

test/constructor.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
'use strict'
33

44
const multiaddr = require('multiaddr')
5-
const chai = require('chai')
6-
const dirtyChai = require('dirty-chai')
7-
const expect = chai.expect
8-
chai.use(dirtyChai)
9-
5+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
106
const f = require('./utils/factory')
117
const ipfsClient = require('../src/index.js')
128

test/custom-headers.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
'use strict'
33

44
const isNode = require('detect-node')
5-
const chai = require('chai')
6-
const dirtyChai = require('dirty-chai')
7-
const expect = chai.expect
8-
chai.use(dirtyChai)
9-
5+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
106
const ipfsClient = require('../src')
117
const f = require('./utils/factory')
128

test/dag.spec.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33

44
'use strict'
55

6-
const chai = require('chai')
7-
const dirtyChai = require('dirty-chai')
8-
const chaiAsPromised = require('chai-as-promised')
9-
const expect = chai.expect
10-
chai.use(dirtyChai)
11-
chai.use(chaiAsPromised)
6+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
127
const { DAGNode } = require('ipld-dag-pb')
138
const CID = require('cids')
149
const ipfsClient = require('../src')

test/diag.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const chai = require('chai')
5-
const dirtyChai = require('dirty-chai')
6-
const expect = chai.expect
7-
chai.use(dirtyChai)
4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
85
const platform = require('browser-process-platform')
9-
106
const ipfsClient = require('../src')
117
const f = require('./utils/factory')
128

test/endpoint-config.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
/* eslint max-nested-callbacks: ["error", 8] */
33
'use strict'
44

5-
const chai = require('chai')
6-
const dirtyChai = require('dirty-chai')
7-
const expect = chai.expect
8-
chai.use(dirtyChai)
5+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
96
const isNode = require('detect-node')
10-
117
const ipfsClient = require('../src')
128
const f = require('./utils/factory')
139

test/exports.spec.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ const multicodec = require('multicodec')
99
const multihash = require('multihashes')
1010
const PeerId = require('peer-id')
1111
const PeerInfo = require('peer-info')
12-
const chai = require('chai')
13-
const dirtyChai = require('dirty-chai')
14-
const expect = chai.expect
15-
chai.use(dirtyChai)
12+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
1613

1714
const IpfsHttpClient = require('../')
1815

test/files-mfs.spec.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
/* eslint max-nested-callbacks: ["error", 8] */
33
'use strict'
44

5-
const chai = require('chai')
6-
const dirtyChai = require('dirty-chai')
7-
const chaiAsPromised = require('chai-as-promised')
8-
const expect = chai.expect
9-
chai.use(dirtyChai)
10-
chai.use(chaiAsPromised)
5+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
116
const loadFixture = require('aegir/fixtures')
127
const mh = require('multihashes')
138
const CID = require('cids')

test/get.spec.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33

44
'use strict'
55

6-
const chai = require('chai')
7-
const dirtyChai = require('dirty-chai')
8-
const chaiAsPromised = require('chai-as-promised')
9-
const expect = chai.expect
10-
chai.use(dirtyChai)
11-
chai.use(chaiAsPromised)
6+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
127
const loadFixture = require('aegir/fixtures')
138

149
const ipfsClient = require('../src')

test/key.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
/* eslint max-nested-callbacks: ["error", 8] */
33
'use strict'
44

5-
const chai = require('chai')
6-
const dirtyChai = require('dirty-chai')
7-
const expect = chai.expect
8-
chai.use(dirtyChai)
9-
5+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
106
const ipfsClient = require('../src')
117
const f = require('./utils/factory')
128

test/lib.configure.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
/* eslint-env mocha, browser */
22
'use strict'
33

4-
const chai = require('chai')
5-
const dirtyChai = require('dirty-chai')
6-
const expect = chai.expect
7-
chai.use(dirtyChai)
4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
85
const Multiaddr = require('multiaddr')
96
const { isBrowser, isWebWorker } = require('ipfs-utils/src/env')
10-
117
const configure = require('../src/lib/configure')
128

139
describe('lib/configure', () => {

test/lib.error-handler.spec.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const chai = require('chai')
5-
const dirtyChai = require('dirty-chai')
4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
65
const { HTTPError } = require('ky-universal')
7-
const expect = chai.expect
8-
chai.use(dirtyChai)
96
const throwsAsync = require('./utils/throws-async')
107
const errorHandler = require('../src/lib/error-handler')
118

test/lib.stream-to-iterable.spec.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const chai = require('chai')
5-
const dirtyChai = require('dirty-chai')
6-
const expect = chai.expect
7-
chai.use(dirtyChai)
4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
85
const toIterable = require('../src/lib/stream-to-iterable')
96

107
describe('lib/stream-to-iterable', () => {

test/log.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
/* eslint max-nested-callbacks: ["error", 8] */
33
'use strict'
44

5-
const chai = require('chai')
6-
const dirtyChai = require('dirty-chai')
7-
const expect = chai.expect
8-
chai.use(dirtyChai)
9-
5+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
106
const ipfsClient = require('../src')
117
const f = require('./utils/factory')
128

test/node/swarm.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
/* eslint-env mocha */
22
'use strict'
33

4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
45
const nock = require('nock')
5-
const chai = require('chai')
6-
const dirtyChai = require('dirty-chai')
7-
const chaiAsPromised = require('chai-as-promised')
8-
const expect = chai.expect
9-
chai.use(dirtyChai)
10-
chai.use(chaiAsPromised)
11-
126
const ipfsClient = require('../../src')
137

148
describe('.swarm.peers', function () {

test/ping.spec.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const chai = require('chai')
5-
const dirtyChai = require('dirty-chai')
6-
const chaiAsPromised = require('chai-as-promised')
7-
const expect = chai.expect
8-
chai.use(dirtyChai)
9-
chai.use(chaiAsPromised)
4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
105
const pull = require('pull-stream/pull')
116
const collect = require('pull-stream/sinks/collect')
127

test/repo.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const chai = require('chai')
5-
const dirtyChai = require('dirty-chai')
6-
const expect = chai.expect
7-
chai.use(dirtyChai)
8-
4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
95
const ipfsClient = require('../src')
106
const f = require('./utils/factory')
117

test/request-api.spec.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const chai = require('chai')
5-
const dirtyChai = require('dirty-chai')
6-
const expect = chai.expect
7-
chai.use(dirtyChai)
4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
85
const isNode = require('detect-node')
96
const ipfsClient = require('../src/index.js')
107
const ndjson = require('ndjson')

test/stats.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const chai = require('chai')
5-
const dirtyChai = require('dirty-chai')
6-
const expect = chai.expect
7-
chai.use(dirtyChai)
8-
4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
95
const ipfsClient = require('../src')
106
const f = require('./utils/factory')
117

test/sub-modules.spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const chai = require('chai')
5-
const dirtyChai = require('dirty-chai')
6-
const expect = chai.expect
7-
chai.use(dirtyChai)
8-
4+
const { expect } = require('interface-ipfs-core/src/utils/mocha')
95
const defaultConfig = require('../src/utils/default-config.js')
106
const config = defaultConfig()
117
config.host = 'test'

0 commit comments

Comments
 (0)