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

373
Visualizações
Cypress: Cannot use import statement outside a module

A team member uses cypress alone without a package.json, IDE setup or framework and receives the following error message:

Cannot use import statement outside a module

The first part of the e2e test looks like this:

describe('Dummy', () => {
  before(() => {
    cy.visit(Cypress.env('baseURL'));
    cy.contains('Log in').click();
    cy.get('input[name="username"]').type('test user').should('have.value', 'test user');
    cy.get('input[name="password"]').type('test password').should('have.value', 'test password');
  });
});

The tests are partially running and the first two commands (visit & contains) work in the example provided.

But when it comes to the line in which a username and password must be entered, the test failed with the error message mentioned above.

I think he is trying to execute it as an ES2015 module, but node.js only understands CommonJS. There are possibilities to fix it in the package.json, but since it doesn’t use a package.json I don't know what to do.

Is there another workaround for this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

See this answer. These are typical things you would define in your (test) code's package.json and/or tsconfig.json (when using TypeScript). Doing this beforehand prevents all sorts of "(doesn't) work(s) on my machine" issues like the the one you just described.

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