Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
How can I use switch between different environments using the new cypress.config.js in Cypress 10x?

I used to have json files under my config folder containing variables for different environments. For example: local.env.json would contain:

{
"baseUrl": "localhost:8080"
}

then another one called uat.env.json would contain:

{
"baseUrl": "https://uat.test.com"
}

and its configured on my plugins/index.ts as:

    const version = config.env.version || 'uat'; // if version is not defined, default to this stable environment
    config.env = require(`../../config/${version}.env.json`);  // load env from json

I will then call it on my tests with cy.visit(Cypress.env().baseUrl)) then pass it on the CI with CYPRESS_VERSION=uat npx cypress run

However, with the new Cypress 10x version, the plugin file has been deprecated and just relies on cypress.config.js. I can't find any example on their documentation on how this can be done (I remember they used to have a page with these scenarios but can't find it now).

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It's possible to use the old plugins/index.ts in the new cypress.config.ts by importing it.

This is the simplest example (with no new config in cypress.config.ts)

import { defineConfig } from 'cypress'
import legacyConfig from './cypress/plugins/index.js'

export default defineConfig({
  e2e: {
    baseUrl: 'http://localhost:1234',
    setupNodeEvents(on, config) {
      return legacyConfig(on, config)  // call legacy config fn and return result
    }
  }
})

The typescript and modules may cause you grief about typings etc. I've not tried it in a typescript project, but it does work in a javascript project.

Alternatively, copy/paste everything from plugins/index.ts instead of calling the legacy function. This might be better as you add more plugins in the future.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda