Is your feature request related to a problem? Please describe.
WP Cypress includes commands like wp, seed, switchUser(), etc. We can run a command in an e2e spec, like this:
cy.wp('media import /path/to/media --porcelain');
which is going to yield an object (as described in cy.exec()) with the following properties:
code
stdout
stderr
However, due to WP Cypress using the ora spinner—which, by default, is using stderr as the stream to write the output to—the result of those commands will be written to stderr.
An example of a yielded object would look like this:
I was expecting stdout to contain 31 (i.e. the attachment ID), but instead I got an empty string, since there was nothing written to stdout.
Describe the solution you'd like
I'd like to be able to get the actual command output (i.e. 31 in the above example) by accessing the stdout property of the yielded object.
I'd expect the yielded object, in this case, to be:
I think that, for backwards compatibility reasons, the stderr should be kept as it is, since someone might be relying on that to get the result of a command.
Describe alternatives you've considered
The value of the stderr property contains the command result—the 31, at the end of the string, is the attachment ID:
"- Running wp media import /path/to/media --porcelain\nwp-cypress \u001b[32m✔\u001b[39m 31",
It is possible to work around the current implementation, by getting the value of the stderr property and doing something like this:
Is your feature request related to a problem? Please describe. WP Cypress includes commands like
wp
,seed
,switchUser()
, etc. We can run a command in an e2e spec, like this:which is going to yield an object (as described in
cy.exec()
) with the following properties:code
stdout
stderr
However, due to WP Cypress using the
ora
spinner—which, by default, is usingstderr
as the stream to write the output to—the result of those commands will be written tostderr
.An example of a yielded object would look like this:
I was expecting
stdout
to contain31
(i.e. the attachment ID), but instead I got an empty string, since there was nothing written tostdout
.Describe the solution you'd like I'd like to be able to get the actual command output (i.e.
31
in the above example) by accessing thestdout
property of the yielded object.I'd expect the yielded object, in this case, to be:
I think that, for backwards compatibility reasons, the
stderr
should be kept as it is, since someone might be relying on that to get the result of a command.Describe alternatives you've considered The value of the
stderr
property contains the command result—the31
, at the end of the string, is the attachment ID:It is possible to work around the current implementation, by getting the value of the
stderr
property and doing something like this:That may work, but it's not ideal. It's highly dependent on the output of the WP-CLI command, looks confusing and is error-prone.
For clarity, the proposed behavior would look like this:
which, IMHO, is much clearer and more readable.
Additional context N/A