vue-cli: cli-plugin-e2e-cypress test throws exception after tests succeed at the end - TypeError: server.stop is not a function
Version
5.0.8
Environment info
macOS 10.15.7
Steps to reproduce
I tried on Cypress 9.5.1 and 10.3.0. After my tests succeed, the server attempts to close, but the cli-plugin-e2e-cypress fails to close the server:
@vue/cli-plugin-e2e-cypress/index.js:49
runner.on('exit', () => server.stop())
^
TypeError: server.stop is not a function
at ChildProcess.<anonymous> (node_modules/@vue/cli-plugin-e2e-cypress/index.js:49:38)
at ChildProcess.emit (node:events:538:35)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
What is expected?
The server should close properly.
What is actually happening?
cli-plugin-e2e-cypress is claiming that there is no stop() function on the server.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 4
- Comments: 20
+1, this is blocking my project upgrading to the latest Cypress version.
+1 Any updates on this?
A temporary fix is to downgrade cli-plugin-e2e-cypress to 4.5.19.
same issue with cypress v10.3.1
In case this is relevant for someone again, here is how I fixed it for our project.
We’ve Vue 2, and were running Cypress 9.5.2, and ran to this error when trying to update it to a more recent version.
Here’s a change that would fix it: https://github.com/vuejs/vue-cli/pull/7288/files
I used patch-package as a devDependency to apply the fix - I did the modifications needed, then ran patch-package for the module. Then, added patch-package to postinstall. Here’s step-by-step for yarn:
yarn install
yarn patch-package @vue/cli-plugin-e2e-cypress
yarn install
Voilà. It should work now. It creates a patch file which it applies at the end of each install to the module.
I agree, quite surprising that this hasn’t been resolved yet. As I work around, I created the following npm script:
"test:e2e-report": "export NODE_ENV=e2e && vue-cli-service serve & wait-on http://localhost:8080/osc/ && cypress run && pkill -f vue-cli-service"
This starts a Vue development server in the background, then runs the Cypress tests, then kills the Vue development server after the Cypress process has exited. This works perfectly in our CI/CD environment (Bamboo), but it has the negative side effect of killing any development servers spun up with vue-cli-service locally. The start-server-and-test module suggested by the Cypress docs (https://docs.cypress.io/guides/continuous-integration/introduction#Boot-your-server) also seems to work quite well and be more targeted, but it seems to require running npm in a child process, which my CI/CD environment doesn’t currently support. In any case, this allows me to run Cypress 12 in CI/CD without having to wait on this fix to the Vue CLI.