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: docs/quickstart/global-setup.md
+34-22Lines changed: 34 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
If you have many tests that require the same container, you may not want to spin up one per test.
4
4
5
5
!!! info
6
-
There is a misconception that containers are heavyweight.
6
+
There is a misconception that containers are heavyweight.
7
7
8
8
Sure, if your container has a slow startup time (e.g., a database, which on startup runs large migration scripts), it may be better to just start and manage one instance. But keep in mind that this limits your tests to run sequentially, and you may need to manage the state of the container between tests.
9
9
@@ -15,38 +15,50 @@ Many popular test frameworks like Jest and Vitest support global setup and teard
15
15
16
16
Here's an example which sets up a single Redis container globally, so it can be reused across tests. In this case we're using Vitest:
`globalSetup` runs in a different global scope than test files. To share data with tests, provide serializable values in setup and read them with `inject`:
44
+
45
+
```js
46
+
import { afterAll, beforeAll, expect, inject, test } from"vitest";
0 commit comments