You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
feat: modularise tests by command, add tools to skip and only (#290)
BREAKING CHANGE: Consumers of this test suite now have fine grained control over what tests are run. Tests can now be skipped and "onlyed" (run only specific tests). This can be done on a test, command and sub-system level. See the updated usage guide for instructions: https://github.com/ipfs/interface-ipfs-core/blob/master/README.md#usage.
This means that tests skips depending on implementation (e.g. go/js), environment (e.g. node/browser) or platform (e.g. macOS/linux/windows) that were previously present in this suite have been removed. Consumers of this library should add their own skips based on the implementation that's being tested and the environment/platform that the tests are running on.
The following other breaking changes have been made:
1. The common object passed to test suites has changed. It must now be a function that returns a common object (same shape and functions as before).
2. The `ipfs.ls` tests (not MFS `ipfs.files.ls`) is now a root level suite. You'll need to import it and use like `tests.ls(createCommon)` to have those tests run.
3. The `generic` suite (an alias to `miscellaneous`) has been removed.
See #290 for more details.
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+72-10
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,7 @@ Include this badge in your readme if you make a new module that implements inter
52
52
## Install
53
53
54
54
In JavaScript land:
55
+
55
56
```js
56
57
npm install interface-ipfs-core
57
58
```
@@ -68,20 +69,81 @@ In Go land:
68
69
69
70
Install `interface-ipfs-core` as one of the dependencies of your project and as a test file. Then, using `mocha` (for Node.js) or a test runner with compatible API, do:
70
71
71
-
```
72
-
var test = require('interface-ipfs-core')
73
-
74
-
var common = {
75
-
setup: function (cb) {
76
-
cb(null, IPFSFactory)
72
+
```js
73
+
consttests=require('interface-ipfs-core')
74
+
75
+
// Create common setup and teardown
76
+
constcreateCommon= () => ({
77
+
// Do some setup common to all tests
78
+
setup (cb) {
79
+
// Must call back with an "IPFS factory", an object with a `spawnNode` method
80
+
cb(null, {
81
+
// Use ipfsd-ctl or other to spawn an IPFS node for testing
82
+
spawnNode (cb) { /* ... */ }
83
+
})
77
84
},
78
-
teardown: function (cb) {
85
+
// Dispose of nodes created by the IPFS factory and any other teardown
86
+
teardown (cb) {
79
87
cb()
80
88
}
81
-
}
89
+
})
90
+
91
+
tests.block(createCommon)
92
+
tests.config(createCommon)
93
+
tests.dag(createCommon)
94
+
// ...etc. (see js/src/index.js)
95
+
```
96
+
97
+
#### Running tests by command
98
+
99
+
```js
100
+
tests.repo.version(createCommon)
101
+
```
102
+
103
+
#### Skipping tests
104
+
105
+
```js
106
+
tests.repo.gc(createCommon, { skip:true }) // pass an options object to skip these tests
0 commit comments