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

337
Vistas
How to import file from general path in cypress?

I have a file called 'contents' in cypress. in my test file I want to import this file.

I do the following :

import contents from 'C:/Users/asus/cypress/support/contents';

But I want to make it more general path (not contain my own path). I tried to import it inside the index file in cypress.

As follow:

import './contents'

But it is not working by this way. Cypress will throw an error that contents is not defined.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Not knowing the data type and assuming that the exact location of the file doesn't matter, I would recommend moving the file to the /fixtures folder and importing it as recommended in the Cypress docs here. So you can use a relative path for the import in your test like:

import contents from '../fixtures/contents';

You can also find an example for importing a JSON file in this answer.

about 4 years ago · Juan Pablo Isaza Denunciar

0

First, you have to export that file

const contents = {
    // Your data
}
export { contents };

You can import files like this way

import { contents } from '../support/contents.js'

If ../support/contents.js is not working Please use ../../ to get the root directory of your system like ../../support/contents.js. Please replace your file extension with .js.

about 4 years ago · Juan Pablo Isaza 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