Tests don't run queries #6917
-
Hello Prisma community! I'm currently trying to write some integration tests that rely on an actual Prisma database, and running into some issues. First question: Second question: import { PrismaClient } from '@prisma/client'
// Neither of these do anything. They don't even break if I make the DB URL incorrect
describe('<redacted>Resolver', () => {
const prisma = new PrismaClient({ log: ['query'] })
beforeAll(async () => {
await prisma.$connect()
})
afterAll(async () => {
await prisma.$disconnect()
})
test('test create', () => {
console.log(`CREATE: ${JSON.stringify(prisma.<redacted>.create({
data: {
objectId: 'test',
},
}))}`)
})
test('test find many', async () => {
console.log(`RESULT: ${JSON.stringify(prisma.<redacted>.findMany({}))}`)
})
}) Here is the output:
Here is my
Lastly, here is the
Note that I have tried all sorts of restarting and reinstalling |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Those were utils to test Prisma - so you are correct that this is very strange in the context you were looking. You made the right choice to ignore it. |
Beta Was this translation helpful? Give feedback.
-
Prisma queries are async and need to be awaited. Right now you are not doing that before logging the results - which at that point in time do not exist. Just putting the queries like this probably does not even start them. If you sprinkle in a few |
Beta Was this translation helpful? Give feedback.
Prisma queries are async and need to be awaited. Right now you are not doing that before logging the results - which at that point in time do not exist. Just putting the queries like this probably does not even start them. If you sprinkle in a few
await
or.then()
the queries should actually be executed.