Using Cypress with Redwood/Prisma

I was fiddling around with testing in Cypress within a Redwood/Prisma application and it works pretty neatly!

It’s very convenient to do database operations using the generated PrismaClient when setting up your tests.

cy.task('db', {
  operation: 'post.create',
  variables: {
    data: randomPost,



It does require some setup with babel, and then I couldn’t figure out how to import the db from the api/src/lib/db.js file, so I just created a new PrismaClient that uses the same SQLite file.

Note: You might want a separate db file and clean db before every test. Not sure how to do that!

Example repo:


This is awesome, could we jump on a call at some stage? I would love to see how this works.

1 Like

Absolutely! Shoot me a message and we can schedule something.

@Robert Could you add this one along side the default scaffolds? This one rw g scaffold post

Here is the code,

@guledali Hey Guled. This was just a little experiment, but I have some more thoughts on making testing easier, but not sure in what form yet. I’m planning on opening a forum topic on that today :slight_smile: