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

I would like some way to run a CLI command from Cypress #126

Closed
mlunoe opened this issue May 3, 2016 · 3 comments
Closed

I would like some way to run a CLI command from Cypress #126

mlunoe opened this issue May 3, 2016 · 3 comments
Assignees
Labels
type: feature New feature that does not currently exist
Milestone

Comments

@mlunoe
Copy link

mlunoe commented May 3, 2016

Problem

Right now I have to rely on an API to be available use cy.request to hit an endpoint to perform the actions I need. However, we do have some functionality that can only be done through the CLI and it would be nice to have access to that through Cypress.

Suggestion

It would be nice to be able to run a CLI command from Cypress, e.g. with cy.spawn.

An example usage could be to ssh into a host and kill a certain process. It could look something like this:

cy.spawn('ssh {host_ip}', 'kill -9 {process_id}');

I'm not sure that's the best API, but this is just to give an idea of what I am looking for.

@brian-mann
Copy link
Member

Executing arbitrary shell commands is easy, but issuing commands to a ssh connection is quite a bit more challenging. ssh is likely something we'd have to implement natively using a specific cy.ssh command but possibly it's better to do this logic in your own application.

What I mean is, you could simply provide a CLI client which handles the internal ssh connection stuff which Cypress doesn't know about.

Example:

// simple script exec
cy.spawn("npm run ssh-kill")

And then you implement the ssh-kill script yourself in bash or in node or whatever you'd like to do.

Also after thinking about it, the command will likely be cy.exec and not cy.spawn. Exec is a better fit because cy.exec would likely expect your process to exit and would block until it does. This is functionally more equivalent to node's exec vs spawn.

Can you think of another / different use case other than establishing a ssh connection?

@brian-mann brian-mann added this to the 0.16.x milestone May 3, 2016
@brian-mann brian-mann added the type: feature New feature that does not currently exist label May 3, 2016
@mlunoe
Copy link
Author

mlunoe commented May 3, 2016

Yes, I think that would cover all of our cases!
One other use case specific to our case is to run a subcommand from our CLI, since it allows for subcommands to be installed for each service. So running a subcommand through our CLI would allow easier access to change the state of different service in the same way.

In general I think we need the ability to change our system in a way that we don't expect the service to able to, and then test how it acts towards it. My initial example was to kill a specific process, but it could also be to shutdown a host or kill a network connection between a service and our system to test if it re-establishes the connection.

Hope that gave you some ideas.

@chrisbreiding chrisbreiding self-assigned this May 13, 2016
@brian-mann brian-mann modified the milestones: 0.16.x, 0.16.0 May 19, 2016
@brian-mann
Copy link
Member

Fixed in 0.16.0.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature New feature that does not currently exist
Projects
None yet
Development

No branches or pull requests

3 participants