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

375
Vistas
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 Respuestas
Responde la pregunta

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 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