Skip to content

Commit cb99939

Browse files
committed
chore: Hard-wrap TESTING.md to make it easier to read in terminal editors
1 parent b7984ab commit cb99939

1 file changed

Lines changed: 58 additions & 39 deletions

File tree

TESTING.md

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ run them. PouchDB has been primarily developed on Linux and macOS, if you are
55
using Windows then these instructions will have problems, we would love your
66
help fixing them though.
77

8-
> [!WARNING] VERY IMPORTANT
9-
> **Always set the `COUCH_HOST` env var to a proper CouchDB for the integration tests!**
8+
> [!WARNING]
9+
> VERY IMPORTANT **Always set the `COUCH_HOST` env var to a proper CouchDB for
10+
> the integration tests!**
1011
>
11-
> If you don’t, the integration tests currently fall back to `pouchdb-server`, which is
12-
> no longer reliable and causes random test failures. (20000ms timeouts).
12+
> If you don’t, the integration tests currently fall back to `pouchdb-server`,
13+
> which is no longer reliable and causes random test failures. (20000ms
14+
> timeouts).
1315
>
14-
> Until this is resolved, please set the `COUCH_HOST` env var:
15-
> `$ CLIENT=firefox COUCH_HOST=http://admin:admin@127.0.0.1:5984 npm test`
16+
> Until this is resolved, please set the `COUCH_HOST` env var: `$ CLIENT=firefox
17+
> COUCH_HOST=http://admin:admin@127.0.0.1:5984 npm test`
1618
>
1719
> This is necessary for both `npm test` and `npm run dev`.
1820
@@ -35,8 +37,8 @@ The PouchDB test suite expects an instance of CouchDB (version 1.6.1 and above)
3537
running in [Admin Party](http://guide.couchdb.org/draft/security.html#party) on
3638
`http://127.0.0.1:5984` with [CORS
3739
enabled](https://github.com/pouchdb/add-cors-to-couchdb). See the [official
38-
CouchDB documentation](https://docs.couchdb.org/en/stable/install/index.html) for
39-
a guide on how to install CouchDB.
40+
CouchDB documentation](https://docs.couchdb.org/en/stable/install/index.html)
41+
for a guide on how to install CouchDB.
4042

4143
If you have CouchDB available at a different URL, you can assign this URL to the
4244
`COUCH_HOST` environment variable to make the PouchDB tests use it.
@@ -62,7 +64,8 @@ The main test suite can be run using the following command:
6264
$ npm test
6365

6466
> [!NOTE]
65-
> If the tests don‘t pass on `main`, try building once before running the tests: `$npm run build`.
67+
> If the tests don‘t pass on `main`, try building once before running the tests:
68+
> `$npm run build`.
6669
6770
PouchDB runs in the browser and on Node.js, and has multiple different storage
6871
backends known as _adapters_. In the browser these are `idb`, `indexeddb` and
@@ -87,10 +90,11 @@ variables.
8790

8891
#### `ADAPTERS` (default: depends on `CLIENT`) <!-- omit from toc -->
8992

90-
Comma-separated list of preferred adapter backends that PouchDB will use for local
91-
databases. These are selected automatically based on the execution environment,
92-
but this variable overrides the default choice and causes additional adapters to
93-
be loaded if they're not part of the default distribution.
93+
Comma-separated list of preferred adapter backends that PouchDB will use for
94+
local databases. These are selected automatically based on the execution
95+
environment, but this variable overrides the default choice and causes
96+
additional adapters to be loaded if they're not part of the default
97+
distribution.
9498

9599
On Node.js the available local adapters are `leveldb` and `memory`. In the
96100
browser they're `idb`, `indexeddb` and `memory`.
@@ -111,8 +115,8 @@ this to `0` to prevent this behaviour.
111115

112116
#### `CLIENT` (default: `node`) <!-- omit from toc -->
113117

114-
Sets the target platform the tests will execute on. Set this to
115-
`firefox`, `chromium` or `webkit` to execute the tests in the browser.
118+
Sets the target platform the tests will execute on. Set this to `firefox`,
119+
`chromium` or `webkit` to execute the tests in the browser.
116120

117121
#### `COUCH_HOST` <!-- omit from toc -->
118122

@@ -183,12 +187,12 @@ Set this to `1` to skip the migration tests.
183187

184188
#### `VIEW_ADAPTERS` (default: `memory`) <!-- omit from toc -->
185189

186-
Comma-separated list of preferred view adapter backends that PouchDB will use.
187-
This variable overrides the default choice and causes additional adapters to
188-
be loaded if they're not part of the default distribution.
190+
Comma-separated list of preferred view adapter backends that PouchDB will use.
191+
This variable overrides the default choice and causes additional adapters to be
192+
loaded if they're not part of the default distribution.
189193

190-
On Node.js the available adapters are `leveldb` and `memory`. In the
191-
browser they're `idb`, `indexeddb` and `memory`.
194+
On Node.js the available adapters are `leveldb` and `memory`. In the browser
195+
they're `idb`, `indexeddb` and `memory`.
192196

193197

194198
## Other sets of tests
@@ -264,12 +268,12 @@ To run tests in the browser, you first have to install playwright:
264268
npx playwright install
265269
```
266270

267-
This will download the `firefox`, `chromium` and `webkit` `CLIENT`s onto
268-
your system.
271+
This will download the `firefox`, `chromium` and `webkit` `CLIENT`s onto your
272+
system.
269273

270274
PouchDB is tested with `CLIENT=firefox`, `CLIENT=chromium` and `CLIENT=webkit`
271-
to run a set of tests in the browser automatically. This runs these browsers
272-
in a “headless” mode and prints the test results back into the terminal.
275+
to run a set of tests in the browser automatically. This runs these browsers in
276+
a “headless” mode and prints the test results back into the terminal.
273277

274278
$ CLIENT=firefox npm test
275279

@@ -278,7 +282,8 @@ server and opening a browser window yourself. To run the server:
278282

279283
$ npm run dev
280284

281-
You will almost always want to include the `find` plugin though, without it, all the `find` tests will fail:
285+
You will almost always want to include the `find` plugin though, without it, all
286+
the `find` tests will fail:
282287

283288
$ PLUGINS=pouchdb-find npm run dev
284289

@@ -289,9 +294,12 @@ Then you can open the page for any of the test suites via the following URLs:
289294
- `http://127.0.0.1:8000/tests/mapreduce/`
290295
- `http://127.0.0.1:8000/tests/performance/`
291296

292-
You can re-run tests by reloading, and only run specific suites by clicking on the suite names, this sets the `grep` query string mentioned below. This works well in conjunction with setting `.only` on individual tests in that suite.
297+
You can re-run tests by reloading, and only run specific suites by clicking on
298+
the suite names, this sets the `grep` query string mentioned below. This works
299+
well in conjunction with setting `.only` on individual tests in that suite.
293300

294-
The test options are controlled by editing the query string; some of the common command-line options and their query string equivalents are:
301+
The test options are controlled by editing the query string; some of the common
302+
command-line options and their query string equivalents are:
295303

296304
| Environment variable | Query-string param |
297305
| -------------------- | ------------------ |
@@ -343,28 +351,39 @@ Checks that the build is correct.
343351

344352
### Where do I get a CouchDB from?
345353

346-
See the [official CouchDB documentation](https://docs.couchdb.org/en/stable/install/index.html) for a guide on how to install CouchDB.
347-
348-
Your CouchDB will most likely then run at `http://127.0.0.1:5984`. All you need to do now is enable CORS so CouchDB will accept requests from PouchDB in the tests. Add `http://127.0.0.1:8000`, the test server’s domain. There are several ways to do this, easiest first:
349-
350-
1. In the [CouchDB admin UI](http://127.0.0.1:5984/_utils), click on `Configuration` -> `CORS`.
351-
2. Via cURL (`_local` is the node name in single-node databases, which your local dev CouchDB probably is):
352-
```sh
353-
curl 'http://admin:password@127.0.0.1:5984/_node/_local/_config/cors/origins' -X PUT -d '"http://127.0.0.1:8000"'
354-
```
355-
3. There’s also an older [npm package](https://github.com/pouchdb/add-cors-to-couchdb) to help you do this porgrammatically.
354+
See the [official CouchDB
355+
documentation](https://docs.couchdb.org/en/stable/install/index.html) for a
356+
guide on how to install CouchDB.
357+
358+
Your CouchDB will most likely then run at `http://127.0.0.1:5984`. All you need
359+
to do now is enable CORS so CouchDB will accept requests from PouchDB in the
360+
tests. Add `http://127.0.0.1:8000`, the test server’s domain. There are several
361+
ways to do this, easiest first:
362+
363+
1. In the [CouchDB admin UI](http://127.0.0.1:5984/_utils), click on
364+
`Configuration` -> `CORS`.
365+
2. Via cURL (`_local` is the node name in single-node databases, which your
366+
local dev CouchDB probably is): ```sh curl
367+
'http://admin:password@127.0.0.1:5984/_node/_local/_config/cors/origins' -X
368+
PUT -d '"http://127.0.0.1:8000"' ```
369+
3. There’s also an older [npm
370+
package](https://github.com/pouchdb/add-cors-to-couchdb) to help you do this
371+
porgrammatically.
356372

357373
### Utils won’t update
358374

359-
If you’re modifying the test utils (`/tests/integration/utils.js` etc.) or adding logs to them, you need to rebuild these before running your tests again, eg.:
375+
If you’re modifying the test utils (`/tests/integration/utils.js` etc.) or
376+
adding logs to them, you need to rebuild these before running your tests again,
377+
eg.:
360378

361379
```sh
362380
$ npm run build && CLIENT=firefox npm test
363381
```
364382

365383
### Flaky tests and random timeouts
366384

367-
If you regularly run into random timeouts, please re-read the top of this file and set the `COUCH_HOST` env var when running tests or the dev server, eg.:
385+
If you regularly run into random timeouts, please re-read the top of this file
386+
and set the `COUCH_HOST` env var when running tests or the dev server, eg.:
368387

369388
```sh
370389
$ CLIENT=firefox COUCH_HOST=http://admin:admin@127.0.0.1:5984 npm test

0 commit comments

Comments
 (0)