Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

329
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda