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
Copy file name to clipboardExpand all lines: README.md
+51Lines changed: 51 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -97,6 +97,57 @@ test("foo bar", async (t) => {
97
97
98
98
## Advanced Usage
99
99
100
+
### Postgres container de-duping
101
+
102
+
In rare cases, you may want to spawn more than one Postgres container.
103
+
104
+
Internally, this library uses an AVA "shared worker". A shared worker is a singleton shared with the entire running test suite, and so one `ava-postgres` shared worker maps to exactly one Postgres container.
105
+
106
+
To spawn separate shared workers and thus additional Postgres containers, you have two options:
107
+
108
+
**Specify different version strings for the `postgresVersion` option in the factory function**:
Each unique key will map to a unique shared worker.
127
+
128
+
### Database de-duping
129
+
130
+
By default, `ava-postgres` will create a new database for each test. If you want to share a database between tests, you can use the `databaseDedupeKey` option:
* Test workers will be de-duped by this key. You probably don't need to set this.
51
+
* In rare cases, you may want to spawn more than one Postgres container.
52
+
* Internally, this library uses an AVA "shared worker". A shared worker is a singleton shared with the entire running test suite, and so one `ava-postgres` shared worker maps to exactly one Postgres container.
53
+
* To spawn separate shared workers and thus additional Postgres containers, you can specify a custom key here.
54
+
* Each unique key will map to a unique shared worker/unique Postgres container.
* If `getTestPostgresDatabase()` is called multiple times with the same `key` and `params`, the same database is guaranteed to be returned.
70
+
* By default, `ava-postgres` will create a new database for each test. If you want to share a database between tests, you can use the `databaseDedupeKey` option.
71
+
* This works across the entire test suite.
72
+
*
73
+
* Note that if unique parameters are passed to the `beforeTemplateIsBaked` (`null` in the above example), separate databases will still be created.
0 commit comments