Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli-plugin-e2e-cypress should allow a different version of cypress #5352

Closed
dholth opened this issue Apr 3, 2020 · 11 comments
Closed

cli-plugin-e2e-cypress should allow a different version of cypress #5352

dholth opened this issue Apr 3, 2020 · 11 comments

Comments

@dholth
Copy link

dholth commented Apr 3, 2020

What problem does this feature solve?

Cypress is always asking users to update, but cli-plugin-e2e-cypress pins the version that will actually be used. Could the plugin give the user more leeway in choosing their version of Cypress? It would need to invoke cypress from the project's node_modules instead of from the cypress stored in the plugin's dependencies.

What does the proposed API look like?

The user would supply a "cypress" : "x.y.z" dependency in their own package.json instead of in node_modules/@vue/cli-plugin-e2e-cypress/package.json

@ghost
Copy link

ghost commented Apr 6, 2020

Temporary workaround until cli-plugin-e2e-cypress upgrades their version

in package.json add the following:

  "resolutions": {
    "cypress": "4.3.0" 
  }

note: you can replace 4.3.0 with your own version. You will get the nag about unsupported version, but it gives you what you want!

The resolutions field says whatever plugins require this dependency, use this version instead.

Note: Using a version not supported by the plugin may have ill-side effects and any issues you may have might be caused by using a different version. I have not had any so far, and you get Firefox support!

@smarandav
Copy link

I do get the below error when using cypress 4.3.0 in this cli-plugin-e2e-cypress and I really need min 4.3.0 version for cypress because of other dependencies. Is the above patch working for you? @EfChouTR @tschoartschi

Error: The handler for the event task must be an object
at createErrorResult (C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\lib\plugins\child\validate_event.js:3:71)
at validate (C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\lib\plugins\child\validate_event.js:7:46)
at isObject (C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\lib\plugins\child\validate_event.js:15:10)
at validateEvent (C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\lib\plugins\child\validate_event.js:42:10)
at register (C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:35:32)
at module.exports (C:\source\RestaurantClaimsWeb\tests\ui\plugins\index.js:2:3)
at C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:75:12
at tryCatcher (C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
at Function.Promise.attempt.Promise.try (C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\method.js:39:29)
at load (C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:72:7)
at EventEmitter. (C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:196:5)
at EventEmitter.emit (events.js:210:5)
at process. (C:\Users.\AppData\Local\Cypress\Cache\4.3.0\Cypress\resources\app\packages\server\lib\plugins\util.js:25:29)
at process.emit (events.js:210:5)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)

@tschoartschi
Copy link

tschoartschi commented Jun 16, 2020

@smarandav we didn't try 4.3.0 but with 4.8.0 it works good for us. It works on our local development environments (which are only Macs) and also on our CI which uses the node:lts docker image. But I can not tell you, if it works on Windows as well 🤔

@ghost
Copy link

ghost commented Jun 16, 2020

@smarandav it looks like you may be running into this issue? cypress-io/cypress#6853

It was always tossed as a warning but never properly caught until v4.2+

if you are requiring task, return the object in the method per the below comment:
cypress-io/cypress#6853 (comment)

@Mikilll94
Copy link

@EfChouTR
This is working only for yarn. What if I use npm?

@ghost
Copy link

ghost commented Aug 19, 2020

@Mikilll94 you would have to use something like https://github.com/rogeriochaves/npm-force-resolutions to achieve the same outcome as yarn's resolutions field

@Mikilll94
Copy link

Mikilll94 commented Aug 19, 2020

@EfChouTR
I have found a better workaround. I have just uninstalled cli-plugin-e2e-cypress and installed cypress package. It's very easy to setup cypress on your own :) This vue-cli plugin is just a very simple wrapper for cypress open command.

@ghost
Copy link

ghost commented Aug 19, 2020

@EfChouTR
I have found a better workaround. I have just uninstalled cli-plugin-e2e-cypress and installed cypress package. It's very easy to setup cypress on your own :) This vue-cli plugin is just a very simple wrapper for cypress open command.

So many different solutions to the same problem; glad you found one that works!

@itsalaidbacklife
Copy link

This would be very helpful. As someone currently using npm, I would prefer not to hack around using npm-resolutions. The ability to open cypress and start the vue server with one command is handy; however the newer versions of cypress have a more robust feature set that (especially source mapping after 4.6.0) which outweight the convenience of a single command imo.

Having the ability to use new versions of cypress with this wrapper would be the best of both worlds

@aranoe
Copy link

aranoe commented Dec 9, 2020

@EfChouTR
I have found a better workaround. I have just uninstalled cli-plugin-e2e-cypress and installed cypress package. It's very easy to setup cypress on your own :) This vue-cli plugin is just a very simple wrapper for cypress open command.

I really wanted to see an example but it is actually pretty easy to setup and run cypress!
For everyone who wants an example, here are the changes to the scripts section in my package.json:

...
scripts {
...
 "serve:cypress": "npm run serve:target & cypress open",
 "serve:target": "serve ./target/dist -p 3000",
 "test:e2e": "npm run build && npm run serve:cypress",
...
}
...

Don't forget to add serve to your dependencies:

npm i serve --only=dev

Accordingly, here is my cypress.json in the root directory:

{
  "pluginsFile": "tests/e2e/plugins/index.js",
  "baseUrl": "http://localhost:3000",
  "includeShadowDom": true 
}

You probably wont need "includeShadowDom": truebut that was the reason, why I needed the update.
Nevertheless, the clie-plugin-e2e-cypress comes in handy for scaffolding your e2e-tests folder structure.

@haoqunjiang
Copy link
Member

Fixed in v4.5.9 and v5.0.0-alpha.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants