Mock database
Summary
- Create the
.env.testfile and put a differentDATABASE_URLthere, pointing at./prisma/test.db.?connection_limit=1is 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).
- Edit
playwright.config.tsto add a newdotenv.configure()to load.env.testwithoverrides: true. This will point the test process to the correct env file. - In
playwright.config.ts, also setwebServer.env(DATABASE_URL: process.env.DATABASE_URL) to use the correct test DB URL. - Create
playwright.setup.tsto (1) reset the test DB before the test run; (2) prepare the test database (generate client + apply the initial migrations). - Edit
playwright.config.tsto use theplaywright.setup.tsas theglobalSetupso Playwright knows when to run it. - Run the existing tests (no test changes in this exercise). See the
prisma/test.dbwritten 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.