Closed LearningProcesss closed 2 years ago
Is it possible that it uses a test database instead of the dev one while running the tests?
Is it possible that it uses a test database instead of the dev one while running the tests?
This, along with a mock \ injection were my first thoughts. Sadly, i cant find an explicit reference. default test/util.tsx file for example contains a full BlitzRouter mock but nothing about db.
Is there any db.$reset()
in the tests? That would clear the db.
yes, blitz comes with forgotPassword.test and resetPassword.test files by default and use it like:
beforeEach(async () => {
await db.$reset()
})
I tried removing that also. does not solve.
Because does not clear the real db, seems to me that this $reset is used to clear a temporary database (as you suggested) or an injected one.
Keep in mind also that i'm executing only my test case
yarn test --verbose -t "Prisma concrete query test"
so i expect that db.$reset() is never called before my test.
"Test database" was the right path to follow. Digging into Prisma documentations i come across Environment doc. Turns out that .env.test.local expose this env key: DATABASE_URL="file:./db_test.sqlite" It was so clear and under my watch that i completely missed it!
Oh cool! Glad you found it
What is the problem?
Only User model data can be retrieved while testing.
Paste all your error logs here:
Paste all relevant code snippets here:
What are detailed steps to reproduce this?
1.
Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem:
Database is filled by relevant model data, i can query with native driver:
sqlite> SELECT COUNT(*) FROM githubrepo; 290