Skip to content

Compatibility issue between cli-plugin-cypress and cli-plugin-babel #2538

Closed
@salvadordiaz

Description

@salvadordiaz

Version

3.0.3

Reproduction link

https://github.com/salvadordiaz/vue-cli-cypress-babel-import-bug

Node and OS info

Node 10.10.0 / yarn 1.9.4 / Ubuntu 18.04.1

Steps to reproduce

  • Create project with vue create and select only babel and e2e tests with cypress
  • Add an import statement to tests/e2e/specs/test.js (for example: import Vue from 'vue')
  • Run e2e tests with yarn test:e2e --headless

What is expected?

Test should pass

What is actually happening?

Test fails with the following output

  Running: test.js...                                                                      (1 of 1) 

Oops...we found an error preparing this test file:

  ~/work/cypress-import-bug/tests/e2e/specs/test.js

The error was:


~/work/cypress-import-bug/node_modules/@babel/runtime/helpers/builtin/es6/interopRequireDefault.js:1
export default function _interopRequireDefault(obj) {
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'

This occurred while Cypress was compiling and bundling your test code. This is usually caused by:

- A missing file or dependency
- A syntax error in the file or one of its dependencies

Fix the error in your code and re-run your tests.

The issue can be worked around by not using cli-plugin-cypress:

  • In the project created precedently, remove @vue/cli-plugin-e2e-cypress from devDependencies in package.json
  • Add cypress 3.0.3 (3.1.0 exhibits the same bug)
  • Copy-paste https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-e2e-cypress/index.js to the root of your project, renaming it vue-cli-plugin-e2e-cypress.js
  • Declare the local plugin created above in package.json by adding "vuePlugins": { "service": ["vue-cli-plugin-e2e-cypress.js"] }
  • The test passes now (this workaround can be found in the branch workaround of the minimal reproduction repo)

It seems that cypress 3.1.0 introduces some changes that make it incompatible with the babel version used in cli-plugin-babel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions