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: exercises/03.guides/01.solution.mock-database/README.mdx
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,9 @@
3
3
## Summary
4
4
5
5
1. Create the `.env.test` file and put a different `DATABASE_URL` there, pointing at `./prisma/test.db`.
6
-
1. Create `playwright.setup.ts` to (1) reset the test DB before the test run; (2) prepare the test database using the same `prisma:setup` script.
6
+
-`?connection_limit=1` is useful since SQLite locks the entire database during writes. This prevents race conditions in tests (one test tries to write to a db while it's locked due to a write from another test).
7
+
1. Edit `playwright.config.ts` to add a new `dotenv.configure()` to load `.env.test` with `overrides: true`. This will point the test process to the correct env file.
8
+
1. In `playwright.config.ts`, also set `webServer.env` (`DATABASE_URL: process.env.DATABASE_URL`) to use the correct test DB URL.
9
+
1. Create `playwright.setup.ts` to (1) reset the test DB before the test run; (2) prepare the test database (generate client + apply the initial migrations).
7
10
1. Edit `playwright.config.ts` to use the `playwright.setup.ts` as the `globalSetup` so Playwright knows when to run it.
8
11
1. Run the existing tests (no test changes in this exercise). See the `prisma/test.db` written on disk. See how it _persists_ after the test run to help with debugging. Open and show what's been created as a part of this test run.
0 commit comments