Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 77ecfef

Browse files
authored
docs: add docs for test strategy (#3144)
1 parent b4d3bf8 commit 77ecfef

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

docs/DEVELOPMENT.md

+39
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
- [Build a dist version](#build-a-dist-version)
77
- [Publishing new versions](#publishing-new-versions)
88
- [Using prerelease versions](#using-prerelease-versions)
9+
- [Testing strategy](#testing-strategy)
10+
- [CLI](#cli)
11+
- [HTTP API](#http-api)
12+
- [Core](#core)
13+
- [Non-Core](#non-core)
914

1015
## Clone and install dependencies
1116

@@ -64,3 +69,37 @@ Please run the linter before submitting a PR, the build will not pass if it fail
6469
## Using prerelease versions
6570

6671
Any changed packages from each successful build of master are published to npm as canary builds under the npm tag `next`.
72+
73+
## Testing strategy
74+
75+
This project has a number of components that have their own tests, then some components that share interface tests.
76+
77+
When adding new features you may need to add tests to one or more of the test suites described below.
78+
79+
### CLI
80+
81+
Tests live in [/packages/ipfs/test/cli](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs/test/cli).
82+
83+
All interactions with IPFS core are stubbed so we just ensure that the correct arguments are passed in
84+
85+
### HTTP API
86+
87+
Tests live in [/packages/ipfs/test/http-api](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs/test/http-api) and are similar to the CLI tests in that we stub out core interactions and inject requests with [shot](https://www.npmjs.com/package/@hapi/shot).
88+
89+
### Core
90+
91+
Anything non-implementation specific should be considered part of the 'Core API'. For example node setup code is not Core, but anything that does useful work, e.g. network/repo/etc interactions would be Core.
92+
93+
All Core APIs should be documented in [/docs/core-api](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api).
94+
95+
All Core APIs should have comprehensive tests in [/packages/interface-ipfs-core](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core).
96+
97+
`interface-ipfs-core` should ensure API compatibility across implementations. Tests are run:
98+
99+
1. Against [/packages/ipfs/src/core](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs/src/core) directly
100+
1. Against [/packages/ipfs/src/http](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs/src/http) over HTTP via `ipfs-http-client`
101+
1. Against `go-ipfs` over HTTP via `ipfs-http-client`
102+
103+
### Non-Core
104+
105+
Any non-core API functionality should have tests in the `tests` directory of the module in question, for example: [/packages/ipfs-http-api/tests](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client/test) and [/packages/ipfs/tests](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs/test) for `ipfs-http-client` and `ipfs` respectively.

0 commit comments

Comments
 (0)