Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

(create-wdio): fix multiple issues, simplify/cleanup code#585

Merged
erwinheitzman merged 10 commits intowebdriverio:mainfrom
erwinheitzman:use-pm-that-is-used
Nov 29, 2023
Merged

(create-wdio): fix multiple issues, simplify/cleanup code#585
erwinheitzman merged 10 commits intowebdriverio:mainfrom
erwinheitzman:use-pm-that-is-used

Conversation

@erwinheitzman
Copy link
Member

@erwinheitzman erwinheitzman commented Nov 28, 2023

Attempt to fix webdriverio/webdriverio#11581

Changes made:

  • Always use the package manager that is used to initiate the project
  • Always create a base package.json if one does not exist in the current directory to later by used by the wdio config command
  • running an empty install is no longer needed as this is handled by the wdio config command already
  • Removed some packages
  • npm is the only package manager that cannot run npm run wdio (where wdio is the binary, not the script) therefore, instead of always using npx, again use the package manager that is used instead

Additionally there's some new logic:

  1. look for @wdio/cli in the current project and use it if found
  2. if @wdio/cli is not installed in the project, check if the package is installed globally and use it if found
  3. if 1 and 2 failed, installed the @wdio/cli package in the current directory

@darkartswizard
Copy link

Thank you for following up on this.
Let me know if you need me to retry the install with npm and yarn.

@erwinheitzman
Copy link
Member Author

erwinheitzman commented Nov 29, 2023

@christian-bromann I resolved all feedback and could remove a bit more code. We do not need to create a package.json anymore as this is done by the @wdio/cli package already :)

@erwinheitzman
Copy link
Member Author

@darkartswizard the issue that it will sometimes use yarn is still an issue that I will tackle separately but any other issues should be resolved with this PR!

@erwinheitzman
Copy link
Member Author

I just implemented a new feature where it will use the @wdio/cli package if it is installed globally.

The logic is now as follows:

  1. look for @wdio/cli in the current project and use it if found
  2. if @wdio/cli is not installed in the project, check if the package is installed globally and use it if found
  3. if 1 and 2 failed, installed the @wdio/cli package in the current directory

I'm very very happy with this progress ^^

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, but looking good !

@erwinheitzman
Copy link
Member Author

Thank you for the swift feedback, I think we are good to go 👍

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, let's 🚢 it 👍

@erwinheitzman erwinheitzman merged commit c3e5fd2 into webdriverio:main Nov 29, 2023
@darkartswizard
Copy link

darkartswizard commented Dec 7, 2023

I tested fresh installs using two approaches and run with both yarn and npm

Video test of both
npm init wdio@latest .
and
npm init wdio .
with yarn and npm are here:
https://www.youtube.com/watch?v=BGVeWi8DU6Q

Findings:

1) New: Regardless if I use
npm init wdio@latest .
or
npm init wdio .

I don't see the WebdriverIO version displayed at install anymore.

Had to look at the package.json to see
"devDependencies": {
"@wdio/cli": "^8.24.13",
"@wdio/local-runner": "^8.24.12",
"@wdio/mocha-framework": "^8.24.12",
"@wdio/spec-reporter": "^8.24.12"

2) When I install with
npm init wdio@latest .
in \child1 and
its parent directory then
yarn wdio
runs as expected

installing in \child2 and \child3
also completes successfully but Yarn fails
yarn wdio 'wdio' is not recognized as an internal or external command, operable program or batch file. error Command failed with exist code 1.

while npm
npm run wdio
works fine from all four directories

3) When I installed this way
npm init wdio .
in \child1 and
its parent directory then
yarn wdio
runs as expected

installing in \child2 and \child3
throws this benign error after an install was performed in the parent directory
⚠️ Ups, something went wrong: Error calling: npx wdio config!
Good news: \child2 and \child3 installs do now complete.

yarn wdio
Works fine from all four directories

npm run wdio
Also works fine from all four directories
YouTube
Paul Grossman
WDIO Install Bug Fix (Yarn vs Npm)
Image

@erwinheitzman
Copy link
Member Author

erwinheitzman commented Dec 7, 2023

Hey @darkartswizard thank you for the video (what software did you use? The zooming is great!).

  1. The version is only shown if a new version is installed, apparently you already had this version locally (it is installed globally).

  2. You should never ever combine different package managers in one project, ever. It creates a lot of problems and this is not something WebdriverIO can fix. If you use yarn, use yarn for everything in that project. If you use bun, use bun for everything in that project, etc. You get the idea.

I hope this clears it all up, thanks for the thorough testing! 😁

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: Install of WDIO into parent folder breaks existing tests and future installs [See Video]

3 participants