0

I have a project that was created with create-t3-app@latest. When I attempt to setup component testing with Cypress it throws an error saying invalid environment variables, it's attempting to use the src/env.mjs file.

I've tried to use cypress.env.json and the env variables in cypress.config.ts to override it but the error is persisting. E2E testing does not throw this error just component testing. Any ideas/suggestions or will I have to use a different testing library? thanks

codings-R-us
  • 11
  • 1
  • 2

1 Answers1

0

You will need to set the NODE_ENV before running cypress:

"scripts": {
    "cypress": "NODE_ENV='test' cypress open"
  }

I think it's just a cypress bug, apparently something was resolved a while ago but it happened again.

https://docs.cypress.io/guides/references/changelog#1-4-2 https://github.com/cypress-io/cypress/issues/22267