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

[📖 Docs]: WDIO CLI - isTTY assumption on "pipe" arguments #10618

Open
2 tasks done
yuri-scarbaci-lenio opened this issue Jun 22, 2023 · 3 comments
Open
2 tasks done
Labels
Docs 📖 help wanted Issues that are free to take by anyone interested

Comments

@yuri-scarbaci-lenio
Copy link

Pre-check

  • I know I can edit the docs but prefer to file this issue

Describe the improvement

Missing documentation

Description of the improvement / report

We are running wdio via a node script invoking the CLI commands,
in our flow we use execa and husky,

due to this assumption:

* called immediately, otherwise piped input is processed, expecting

when using default execa behaviour with standard husky pre-push hook behaviour we have got a very hard to track bug on our side,

I would love to contribute to document this myself if someone can point me to where I should add the documentation for the WDIO CLI behaviours

more infos:

Code of Conduct

  • I agree to follow this project's Code of Conduct
@yuri-scarbaci-lenio yuri-scarbaci-lenio added Docs 📖 Needs Triaging ⏳ No one has looked into the issue yet labels Jun 22, 2023
@christian-bromann
Copy link
Member

Can you explain a bit more about your issue and what documentation you like to add?

@christian-bromann christian-bromann added Information Missing and removed Needs Triaging ⏳ No one has looked into the issue yet labels Jun 22, 2023
@yuri-scarbaci-lenio
Copy link
Author

yuri-scarbaci-lenio commented Jun 23, 2023

Yep, let me explain our use case for starter:
we have a combination of

  • wdio (used via node invoking the CLI commands)
  • execa (used to invoke wdio via cli from node)
  • husky (used to hook to pre-push hook)

the way we tied up the flow this is more or less what happens:

  • developer tries to push his pending work
  • husky run the pre-push hook
    • in the pre-push hook we run a node scripts that loads the wdio based on some peculiar scaffolding we mounted to share the same wdio config across multiple projects
    • the node script runs the command
      execa('wdio', [ ...ourDynamicWdioFlagsLikeSpecConfigAndSuch ],  {stdio:'inherit'} )
    

case 1 - executing the node script from husky

The hook is called with two parameters which provide the name and location of the destination remote, if a named remote is not being used both values will be the same.

case 2 - executing the node script manually from the developer own terminal

there is no pending "pipe", the command doesn't overwrite the config.spec

This is pretty much custom logic, what's the problem with wdio documentation then?

webdriverio/packages/wdio-cli/src/commands/run.ts

/**
     * if stdin.isTTY, then no piped input is present and launcher should be
     * called immediately, otherwise piped input is processed, expecting
     * a list of files to process.
     *
     * stdin.isTTY is false when command is from nodes spawn since it's treated as a pipe
     */

I can't find any documentation (maybe I am just not finding it myself, if that's the case please point me to the documentation where this is covered) that documents this "assumption" that the wdio - cli is making that if stdin.isTTY is false, the "pipe" must contain a list of files to process and that this behaviour can not be over-loaded even if you provide the --spec argument to the wdio cli (as in, wdio --spec *.spec.ts would still expect the "spec" to come from the pipe if any pipe is present )

I don't think that our flow is a "strange" flow to have, it makes sense to me that pre-push developers may want to run a suite of smoke e2e, and if that's the case, it also somewhat common that the tool used for this is husky, and the assumption wdio is making about the piped-in arguments is an assumption that goes against this flow by design
(pre-push hook doesn't pipe in files, it pipes in remote refs from git)

having some documentation addressing this flow may prove useful to many people,
some kind of "gotcha" section for implementing such a flow correctly
on top of having a clearly identified callout to:
- the assumption on the "pipe" that MUST be a list of file no matter what (and it can't be ignored nor overwritten explicitly)
- the spec not being over-writable via the --spec argument if stdin has a pending pipe
per

params.spec = stdinData.trim().split(/\r?\n/)
arguments are completely ignored when entering this launchWithStdin flow in wdio
- the assumption being based on stdin.isTTY

Please let me know what your thoughts are regarding this, if I am missing an already existing documentation and/or if further clarification is required on my side

@christian-bromann
Copy link
Member

@yuri-scarbaci-lenio thanks for the clarification.

Yes we do not have any documentation about piping files into the WebdriverIO command. I would suggest to add a section to https://webdriver.io/docs/organizingsuites describing this workflow.

Would you like to take a stab at this since you know most about this?

@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested and removed Information Missing labels Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs 📖 help wanted Issues that are free to take by anyone interested
Projects
None yet
Development

No branches or pull requests

2 participants