Skip to content

Commit 23ac4ec

Browse files
committed
03/01: update solution steps
1 parent 4b2bb4b commit 23ac4ec

File tree

1 file changed

+4
-1
lines changed
  • exercises/03.guides/01.solution.mock-database

1 file changed

+4
-1
lines changed

exercises/03.guides/01.solution.mock-database/README.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
## Summary
44

55
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).
710
1. Edit `playwright.config.ts` to use the `playwright.setup.ts` as the `globalSetup` so Playwright knows when to run it.
811
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

Comments
 (0)