https://cypress.io logo
Need to access .env baseUrl, without dotenv depend...
# i-need-help
c
Hello, originally I had
dotenv
imported into my
cypress.config.ts
and that's OK, but upgraded and now
dotenv
is included in my nuxt dependancy, so I no longer need it for anywhere else in the project, and im reluctant to keep it just for cypress - so I thought OK, what if I put that in
nuxt.config.js
like so
Copy code
export default {
  env: {
          baseUrl: process.env.BASE_URL
        }
}
and then back in
cypress.config.ts
I have
Copy code
import nuxtConfig from './nuxt.config.js'
const { baseUrl } = nuxtConfig.env

export default defineConfig({
  e2e: {
    env: {
      baseUrl,
    },
// rest of file
but this doesn't work. I also tried
Copy code
export default defineConfig({
  e2e: {
    baseUrl,
but again no joy. eventually anyway in my test file I have
cy.visit('/')
but basically that baseUrl always results in the failrue
tldr, I have a value in
.env
and I need cypress to use it for baseUrl, without the additional
dotenv
dependancy that nuxt now contains
oh
maybe am a big idiot
2 Views