debrijja
PPrisma
•Created by debrijja on 6/17/2024 in #help-and-questions
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.
2 replies