i'm trying to run some cypress tests on a next.js ...
# orm-help
j
i'm trying to run some cypress tests on a next.js app using prisma. i'd like to run a prisma seed file before the tests run, so i can be sure there is predictable test data in the db. in
/cypress/plugins/index.js
i have:
Copy code
const seedDb = require("../../prisma/seed.js")

module.exports = on => {
  on("task", {
    resetDb: async () => {
      await seedDb()
      return true
    },
  })
}
which works fine, but my prisma seed file can't find the database url: 😞
Copy code
const { PrismaClient } = require("@prisma/client")
const prisma = new PrismaClient()

const main = async () => {
  // make stuff here
}

main()
  .catch(e => {
    console.error(e)
    process.exit(1)
  })
  .finally(async () => {
    await prisma.$disconnect()
  })

module.exports = main
i'm invoking it using a command like this in my npm scripts, like the docs suggest
Copy code
"cypress": "dotenv -e .env.test next dev & cypress open",
and i have a
.env.test
file defined with a working
DATABASE_URL
string. what am i doing wrong?
r
@Jaye 👋 I don’t think Cypress supports it this way. Have a look at the docs for this very section: https://docs.cypress.io/guides/guides/environment-variables#Option-5-Plugins