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?