P
Prisma3mo ago
debrijja

Prisma seed data erased during testing in single test file run

Hello all, I've been using prisma for a couple years now so I'm relatively familiar with the ORM and I'm a big fan . However I'm having this problem. I've searched online and haven't found a solution. Here's the situation: * I have a postgres test db running in docker. * It's seeded using the standard seed.ts method. * I can console log in the beforeAll and see that the seed data exists * I have no beforeEach or afterEach running * Operations that don't need the seed data work just fine Here's the problem: When I try to create a new record that needs to connect to an existing record I get an error that the existing record doesn't exist! Sure enough if I console log the table of the existing records it's blank. Even if I check in the very first test the data is already gone even though I can check at the end of the beforeAll and it's there. Anyone have any idea what's going on? It's an open source project that I own so I could publish the branch and link it if that would help. The official docs don't use the seeding method for integration testing they just create the data in the beforeAll. I have quite a bit of seed data and don't want to have to write new functions in the test file. I was hoping this would work intuitively. Thanks in advance for any assistance.
1 Reply
debrijja
debrijja3mo ago
I ended up pushing up the branch anyway. Here is a link to the file in question. Also I'm entirely self taught when it comes to nestjs and prisma so I'm also open to any advice on the rest of the project files as well! https://github.com/amrtgaber/aoe2-data-api/blob/feature/add-drafts/test/app.e2e-spec.ts
GitHub
aoe2-data-api/test/app.e2e-spec.ts at feature/add-drafts · amrtgabe...
Fan made data api for Age of Empires II game. Contribute to amrtgaber/aoe2-data-api development by creating an account on GitHub.
Want results from more Discord servers?
Add your server