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
If you have CouchDB available at a different URL, you can assign this URL to the
42
44
`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:
62
64
$ npm test
63
65
64
66
> [!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`.
66
69
67
70
PouchDB runs in the browser and on Node.js, and has multiple different storage
68
71
backends known as _adapters_. In the browser these are `idb`, `indexeddb` and
@@ -87,10 +90,11 @@ variables.
87
90
88
91
#### `ADAPTERS` (default: depends on `CLIENT`) <!-- omit from toc -->
89
92
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.
94
98
95
99
On Node.js the available local adapters are `leveldb` and `memory`. In the
96
100
browser they're `idb`, `indexeddb` and `memory`.
@@ -111,8 +115,8 @@ this to `0` to prevent this behaviour.
111
115
112
116
#### `CLIENT` (default: `node`) <!-- omit from toc -->
113
117
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.
116
120
117
121
#### `COUCH_HOST`<!-- omit from toc -->
118
122
@@ -183,12 +187,12 @@ Set this to `1` to skip the migration tests.
183
187
184
188
#### `VIEW_ADAPTERS` (default: `memory`) <!-- omit from toc -->
185
189
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.
189
193
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`.
192
196
193
197
194
198
## Other sets of tests
@@ -264,12 +268,12 @@ To run tests in the browser, you first have to install playwright:
264
268
npx playwright install
265
269
```
266
270
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.
269
273
270
274
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.
273
277
274
278
$ CLIENT=firefox npm test
275
279
@@ -278,7 +282,8 @@ server and opening a browser window yourself. To run the server:
278
282
279
283
$ npm run dev
280
284
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:
282
287
283
288
$ PLUGINS=pouchdb-find npm run dev
284
289
@@ -289,9 +294,12 @@ Then you can open the page for any of the test suites via the following URLs:
289
294
-`http://127.0.0.1:8000/tests/mapreduce/`
290
295
-`http://127.0.0.1:8000/tests/performance/`
291
296
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.
293
300
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:
295
303
296
304
| Environment variable | Query-string param |
297
305
| -------------------- | ------------------ |
@@ -343,28 +351,39 @@ Checks that the build is correct.
343
351
344
352
### Where do I get a CouchDB from?
345
353
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
package](https://github.com/pouchdb/add-cors-to-couchdb) to help you do this
371
+
porgrammatically.
356
372
357
373
### Utils won’t update
358
374
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.:
360
378
361
379
```sh
362
380
$ npm run build && CLIENT=firefox npm test
363
381
```
364
382
365
383
### Flaky tests and random timeouts
366
384
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.:
368
387
369
388
```sh
370
389
$ CLIENT=firefox COUCH_HOST=http://admin:admin@127.0.0.1:5984 npm test
0 commit comments