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
When using PostgreSQL as a test database, I get sporadic failing tests (mostly resetPassword.test.ts), because tests are run in parallel and then race conditions happen while resetting the database with db.$reset(). I am not sure if this also happens with SQLite. Maybe not because it is simply faster. But we should make sure that those race conditions won't happen. One option would be to run Jest with --runInBand option. This make the whole test suite slower, but it is the easiest way to fix this. There are a lot of other ways to solve this (mostly more complicated, but keeping parallel testing). One is to create a new database for every test and destroying it afterwards. Another one is to roll back the transaction somehow (I think Django does it that way). I am sure there are several others.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When using PostgreSQL as a test database, I get sporadic failing tests (mostly
resetPassword.test.ts
), because tests are run in parallel and then race conditions happen while resetting the database withdb.$reset()
. I am not sure if this also happens with SQLite. Maybe not because it is simply faster. But we should make sure that those race conditions won't happen. One option would be to run Jest with--runInBand
option. This make the whole test suite slower, but it is the easiest way to fix this. There are a lot of other ways to solve this (mostly more complicated, but keeping parallel testing). One is to create a new database for every test and destroying it afterwards. Another one is to roll back the transaction somehow (I think Django does it that way). I am sure there are several others.Resources:
https://github.com/Quramy/jest-prisma
https://jaketrent.com/post/isolate-jest-integration-test-shared-database/
https://stackoverflow.com/a/60819664/166229
https://blog.ludicroushq.com/a-better-way-to-run-integration-tests-with-prisma-and-postgresql
https://www.prisma.io/docs/guides/testing/integration-testing
prisma/prisma#2083 (comment)
https://selimb.hashnode.dev/speedy-prisma-pg-tests
Beta Was this translation helpful? Give feedback.
All reactions