Giter Site home page Giter Site logo

create-wdio's Introduction

WebdriverIO Starter Toolkit Test Changes PRs Welcome

Logo

One command to create a fresh WebdriverIO project or add WebdriverIO to an existing project.

create-wdio works on macOS, Windows, and Linux.
If something doesn’t work, please file an issue.
If you have questions or need help, please ask in our Discord Support channel.

Example

Usage

To install a WebdriverIO project, you may choose one of the following methods:

npx

npx create-wdio@latest ./e2e

npx is a package runner tool that comes with npm 5.2+ and higher, see instructions for older npm versions

npm

npm init wdio@latest ./e2e

npm init <initializer> is available in npm 6+

yarn

yarn create wdio@latest ./e2e

yarn create <starter-kit-package> is available in Yarn 0.25+

pnpm

pnpm create wdio ./e2e

pnpm create <starter-kit-package> is available in pnpm v7+

It will create a directory called e2e inside the current folder. Then it will run the configuration wizard that will help you set-up your framework.

Supported Options

You can pass the following command line flags to modify the bootstrap mechanism:

  • --dev - Install all packages as devDependencies (default: true)
  • --yes - Will fill in all config defaults without prompting (default: false)
  • --npm-tag - use a specific NPM tag for @wdio/cli package (default: latest)

For more information on WebdriverIO see the homepage.

create-wdio's People

Contributors

badisi avatar christian-bromann avatar dependabot[bot] avatar erwinheitzman avatar oss-sauce-bot avatar seanpoulter avatar vigneshmohan243 avatar wdio-bot avatar wswebcreation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

create-wdio's Issues

Increase test coverage

Our current test coverage is pretty low. It would be nice to get at least to a global coverage of about 80%.

Cancelling the configuration wizard still returns success message

Once you enter the configuration wizard and try to exit the process through e.g. CTRL+C a success message is shown at the end, e.g.:

Running WDIO CLI Wizard...

=========================
WDIO Configuration Helper
=========================

? Where is your automation backend located? On my local machine
? Which framework do you want to use? (Use arrow keys)
❯ mocha
  jasmine
  cucumber
----- CTRL+C was pressed here -----
Adding "wdio" script to package.json.
✔ Success!

🤖 Successfully setup project at /private/tmp/demo 🎉

Join our Gitter community and instantly find answers to your issues or queries. Or just join and say hi 👋!
  🔗 https://gitter.im/webdriverio/webdriverio

Visit the project on GitHub to report bugs 🐛 or raise feature requests 💡:
  🔗 https://github.com/webdriverio/webdriverio

To start the test, run: $ npm run wdio

Expected Behavior

Just cancel the process and don't show any message.

[🐛 Bug]: Fix configuration wizard workflow when using `pnpm`

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

latest

Mode

WDIO Testrunner

Which capabilities are you using?

n/a

What happened?

When calling pnpm create wdio an error is thrown.

What is your expected behavior?

The workflow should work as smooth as with npm and yarn.

How to reproduce the bug.

n/a

Relevant log output

pnpm create wdio@latest .
.../../../.pnpm-store/v3/tmp/dlx-14824   |  +50 +++++
.../../../.pnpm-store/v3/tmp/dlx-14824   | Progress: resolved 50, reused 48, downloaded 2, added 50, done

                      **** WDIO LOGO REMVOED *****

                           Webdriver.IO
              Next-gen browser and mobile automation
                    test framework for Node.js


Installing @wdio/cli to initialize project...


⚠️  Ups, something went wrong: Error calling: npm install --save-dev --loglevel error @wdio/cli@latest!

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

[🐛 Bug]: npm script refers to wrong config when using TypeScript

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

7.16.13

Node.js Version

14.18.2

Mode

Standalone Mode

Which capabilities are you using?

No response

What happened?

When I initialized wdio in my project, selecting TypeScript as compiler, the CLI created a wdio.config.ts (config file in TypeScript). This is fine, but at the same time, it added a npm script to package.json which refers to wdio.config.js (config file in JavaScript).

It also didn't take into account, where the wdio.config.js/ts was located. Even though I used default values for the initialization (expect using Jasmine and TypeScript), it thought my wdio.config.js/ts was located in the root of the project, but itself created it in ./test/.

What is your expected behavior?

I expected that the CLI would know what file extension the wdio config would have, and where it would be created, so the npm script in package.json would be correct.

How to reproduce the bug.

  1. I ran npm init wdio .
  2. Used default values for the questions except for the following:
    • Which framework do you want to use? jasmine
    • Do you want to use a compiler? TypeScript
  3. Now the npm script in package.json would be "wdio": "wdio run wdio.conf.js"

Relevant log output

Running WDIO CLI Wizard...

=========================
WDIO Configuration Helper
=========================

? Where is your automation backend located? On my local machine
? Which framework do you want to use? jasmine
? Do you want to use a compiler? TypeScript (https://www.typescriptlang.org/)
? Where are your test specs located? ./test/specs/**/*.ts
? Do you want WebdriverIO to autogenerate some test files? Yes
? Do you want to use page objects (https://martinfowler.com/bliki/PageObject.html)? Yes
? Where are your page objects located? ./test/pageobjects/**/*.ts
? Which reporter do you want to use? spec
? Do you want to add a plugin to your test setup? 
? Do you want to add a service to your test setup? chromedriver
? What is the base url? http://localhost

Installing wdio packages:
- @wdio/local-runner
- @wdio/jasmine-framework
- @wdio/spec-reporter
- wdio-chromedriver-service
- chromedriver

up to date, audited 2836 packages in 12s

191 packages are looking for funding
  run `npm fund` for details

56 vulnerabilities (2 low, 47 moderate, 7 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

Packages installed successfully, creating configuration file...

Config file installed successfully, creating test files...
To have TypeScript support please add the following packages to your "types" list:
{
  "compilerOptions": {
    "types": ["node", "webdriverio/async", "@wdio/jasmine-framework", "expect-webdriverio"]
  }
}

For for information on TypeScript integration check out: https://webdriver.io/docs/typescript


Configuration file was created successfully!
To run your tests, execute:
$ npx wdio run test/wdio.conf.ts

Adding scripts to package.json

🤖 Successfully setup project at /Users/morten/Projects/awesome-project 🎉
To start the test, run: $ npm run wdio
  awesome-project git:(wdio)  npm run wdio

> micro-frontend-tools@0.0.0 wdio
> wdio run wdio.conf.js

? Error: Could not execute "run" due to missing configuration. Would you like to create one? No

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

[🐛 Bug]: Using starter toolkit does not work using yarn

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

16.14.2

Mode

Standalone Mode

Which capabilities are you using?

No response

What happened?

While trying to use the starter toolkit, I keep getting this error.

marccaballero@LM-SJC-11016683 checkout % yarn create wdio .                          
yarn create v1.22.11
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Installed "[email protected]" with binaries:
      - create-wdio
[#############] 13/13
                 -:...........................-:.
                 +                              +
              `` +      `...`        `...`      + `
            ./+/ +    .:://:::`    `::///::`  ` + ++/.
           .+oo+ +    /:+ooo+-/    /-+ooo+-/ ./ + +oo+.
           -ooo+ +    /-+ooo+-/    /-+ooo+-/ .: + +ooo.
            -+o+ +    `::///:-`    `::///::`    + +o+-
             ``. /.     `````        `````     .: .``
                  .----------------------------.
           `-::::::::::::::::::::::::::::::::::::::::-`
          .+oooo/:------------------------------:/oooo+.
      `.--/oooo-                                  :oooo/--.`
    .::-``:oooo`                                  .oooo-``-::.
  ./-`    -oooo`--.: :.--                         .oooo-    `-/.
 -/`    `-/oooo////////////////////////////////////oooo/.`    `/-
`+`   `/+oooooooooooooooooooooooooooooooooooooooooooooooo+:`   .+`
-/    +o/.:oooooooooooooooooooooooooooooooooooooooooooo:-/o/    +.
-/   .o+  -oooosoooososssssooooo------------------:oooo- `oo`   +.
-/   .o+  -oooodooohyyssosshoooo`                 .oooo-  oo.   +.
-/   .o+  -oooodooysdooooooyyooo` `.--.``     .:::-oooo-  oo.   +.
-/   .o+  -oooodoyyodsoooooyyooo.//-..-:/:.`.//.`./oooo-  oo.   +.
-/   .o+  -oooohsyoooyysssysoooo+-`     `-:::.    .oooo-  oo.   +.
-/   .o+  -ooooosooooooosooooooo+//////////////////oooo-  oo.   +.
-/   .o+  -oooooooooooooooooooooooooooooooooooooooooooo-  oo.   +.
-/   .o+  -oooooooooooooooooooooooooooooooooooooooooooo-  oo.   +.
-+////o+` -oooo---:///:----://::------------------:oooo- `oo////+-
+ooooooo/`-oooo``:-```.:`.:.`.+/-    .::::::::::` .oooo-`+ooooooo+
oooooooo+`-oooo`-- `/` .:+  -/-`/`   .::::::::::  .oooo-.+oooooooo
+-/+://-/ -oooo-`:`.o-`:.:-````.:    .///:``````  -oooo-`/-//:+:-+
: :..--:-:.+ooo+/://o+/-.-:////:-....-::::-....--/+ooo+.:.:--.-- /
- /./`-:-` .:///+/ooooo/+///////////////+++ooooo/+///:. .-:.`+./ :
:-:/.           :`ooooo`/`              .:.ooooo :           ./---
                :`ooooo`/`              .:.ooooo :
                :`ooooo./`              .:-ooooo :
                :`ooooo./`              .:-ooooo :
            `...:-+++++:/.              ./:+++++-:...`
           :-.````````/../              /.-:````````.:-
          -/::::::::://:/+             `+/:+::::::::::+.
          :oooooooooooo++/              +++oooooooooooo-
 
                           Webdriver.IO
              Next-gen browser and mobile automation
                    test framework for Node.js


Installing @wdio/cli to initialize project...
file:///Users/marccaballero/.config/yarn/global/node_modules/create-wdio/build/utils.js:16
                return reject(new Error((error && error.message) ||
                              ^

Error: Error calling: npm install --save-dev --loglevel error @wdio/cli@latest
    at ChildProcess.<anonymous> (file:///Users/marccaballero/.config/yarn/global/node_modules/create-wdio/build/utils.js:16:31)
    at ChildProcess.emit (node:events:526:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
error Command failed.
Exit code: 1
Command: /Users/marccaballero/.yarn/bin/create-wdio
Arguments: .
Directory: /Users/marccaballero/checkout/checkout
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

Initially I though it may be related to the M1 chip since I have noticed multiple libraries have had issue with this chip, but I tested in a previous version of a mac pro and it is still failing for the same reason, as you can see there's no output message shown in the error so this is what I can deliver

What is your expected behavior?

That the toolkit works or having documentation to manually integrate the library

How to reproduce the bug.

Using node v16.14.2
running yarn create wdio .

Relevant log output

marccaballero@LM-SJC-11016683 checkout % yarn create wdio .                          
yarn create v1.22.11
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Installed "[email protected]" with binaries:
      - create-wdio
[#############] 13/13
                 -:...........................-:.
                 +                              +
              `` +      `...`        `...`      + `
            ./+/ +    .:://:::`    `::///::`  ` + ++/.
           .+oo+ +    /:+ooo+-/    /-+ooo+-/ ./ + +oo+.
           -ooo+ +    /-+ooo+-/    /-+ooo+-/ .: + +ooo.
            -+o+ +    `::///:-`    `::///::`    + +o+-
             ``. /.     `````        `````     .: .``
                  .----------------------------.
           `-::::::::::::::::::::::::::::::::::::::::-`
          .+oooo/:------------------------------:/oooo+.
      `.--/oooo-                                  :oooo/--.`
    .::-``:oooo`                                  .oooo-``-::.
  ./-`    -oooo`--.: :.--                         .oooo-    `-/.
 -/`    `-/oooo////////////////////////////////////oooo/.`    `/-
`+`   `/+oooooooooooooooooooooooooooooooooooooooooooooooo+:`   .+`
-/    +o/.:oooooooooooooooooooooooooooooooooooooooooooo:-/o/    +.
-/   .o+  -oooosoooososssssooooo------------------:oooo- `oo`   +.
-/   .o+  -oooodooohyyssosshoooo`                 .oooo-  oo.   +.
-/   .o+  -oooodooysdooooooyyooo` `.--.``     .:::-oooo-  oo.   +.
-/   .o+  -oooodoyyodsoooooyyooo.//-..-:/:.`.//.`./oooo-  oo.   +.
-/   .o+  -oooohsyoooyysssysoooo+-`     `-:::.    .oooo-  oo.   +.
-/   .o+  -ooooosooooooosooooooo+//////////////////oooo-  oo.   +.
-/   .o+  -oooooooooooooooooooooooooooooooooooooooooooo-  oo.   +.
-/   .o+  -oooooooooooooooooooooooooooooooooooooooooooo-  oo.   +.
-+////o+` -oooo---:///:----://::------------------:oooo- `oo////+-
+ooooooo/`-oooo``:-```.:`.:.`.+/-    .::::::::::` .oooo-`+ooooooo+
oooooooo+`-oooo`-- `/` .:+  -/-`/`   .::::::::::  .oooo-.+oooooooo
+-/+://-/ -oooo-`:`.o-`:.:-````.:    .///:``````  -oooo-`/-//:+:-+
: :..--:-:.+ooo+/://o+/-.-:////:-....-::::-....--/+ooo+.:.:--.-- /
- /./`-:-` .:///+/ooooo/+///////////////+++ooooo/+///:. .-:.`+./ :
:-:/.           :`ooooo`/`              .:.ooooo :           ./---
                :`ooooo`/`              .:.ooooo :
                :`ooooo./`              .:-ooooo :
                :`ooooo./`              .:-ooooo :
            `...:-+++++:/.              ./:+++++-:...`
           :-.````````/../              /.-:````````.:-
          -/::::::::://:/+             `+/:+::::::::::+.
          :oooooooooooo++/              +++oooooooooooo-
 
                           Webdriver.IO
              Next-gen browser and mobile automation
                    test framework for Node.js


Installing @wdio/cli to initialize project...
file:///Users/marccaballero/.config/yarn/global/node_modules/create-wdio/build/utils.js:16
                return reject(new Error((error && error.message) ||
                              ^

Error: Error calling: npm install --save-dev --loglevel error @wdio/cli@latest
    at ChildProcess.<anonymous> (file:///Users/marccaballero/.config/yarn/global/node_modules/create-wdio/build/utils.js:16:31)
    at ChildProcess.emit (node:events:526:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
error Command failed.
Exit code: 1
Command: /Users/marccaballero/.yarn/bin/create-wdio
Arguments: .
Directory: /Users/marccaballero/checkout/checkout
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Is there an existing issue for this?

- [X] I have searched the existing issues

Wrong file structure in existing TypeScript projects

In a fresh TypeScript project that has some unit tests under ./test I created a new wdio project using the following command:

$ npm init wdio ./test

With the following answers:

? Where is your automation backend located? On my local machine
? Which framework do you want to use? mocha
? Do you want to use a compiler? TypeScript (https://www.typescriptlang.org/)
? Where are your test specs located? ./e2e
? Do you want WebdriverIO to autogenerate some test files? Yes
? Do you want to use page objects (https://martinfowler.com/bliki/PageObject.html)? No
? Which reporter do you want to use? spec
? Do you want to add a plugin to your test setup?
? Do you want to add a service to your test setup? vscode
? What is the base url? http://localhost
? Do you want me to run `npm install` Yes

Which resulted into this file structure:
Screenshot 2022-04-06 at 19 02 07

It seems that:

  • the ./test/e2e folder is not generated
  • the example test is in a wrong directory
  • a package.json is generated even though the project already has one

[🐛 Bug]: Can't install on Windows in monrepo

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest (as of 2024-01-23)

Node.js Version

v20.11.0 (Windows 10)

Mode

WDIO Testrunner

Which capabilities are you using?

No response

What happened?

Tried to set up wdio by running npm init wdio@latest .

What is your expected behavior?

To have wdio set up and ready to run.

How to reproduce the bug.

  1. Check out https://github.com/humanwhocodes/fsx
  2. npm install at the top level
  3. cd packages/memory
  4. npm init wdio@latest .

Relevant log output

$ npm init wdio@latest .
Need to install the following packages:
  create-wdio@latest
Ok to proceed? (y) y

                 -:...........................-:.
                 +                              +        
              `` +      `...`        `...`      + `      
            ./+/ +    .:://:::`    `::///::`  ` + ++/.   
           .+oo+ +    /:+ooo+-/    /-+ooo+-/ ./ + +oo+.  
           -ooo+ +    /-+ooo+-/    /-+ooo+-/ .: + +ooo.  
            -+o+ +    `::///:-`    `::///::`    + +o+-   
             ``. /.     `````        `````     .: .``    
                  .----------------------------.
           `-::::::::::::::::::::::::::::::::::::::::-`  
          .+oooo/:------------------------------:/oooo+. 
      `.--/oooo-                                  :oooo/--.`
    .::-``:oooo`                                  .oooo-``-::.
  ./-`    -oooo`--.: :.--                         .oooo- 
   `-/.
 -/`    `-/oooo////////////////////////////////////oooo/.`    `/-
`+`   `/+oooooooooooooooooooooooooooooooooooooooooooooooo+:`   .+`
-/    +o/.:oooooooooooooooooooooooooooooooooooooooooooo:-/o/    +.
-/   .o+  -oooosoooososssssooooo------------------:oooo- 
`oo`   +.
-/   .o+  -oooodooohyyssosshoooo`                 .oooo- 
 oo.   +.
-/   .o+  -oooodooysdooooooyyooo` `.--.``     .:::-oooo- 
 oo.   +.
-/   .o+  -oooodoyyodsoooooyyooo.//-..-:/:.`.//.`./oooo- 
 oo.   +.
-/   .o+  -oooohsyoooyysssysoooo+-`     `-:::.    .oooo- 
 oo.   +.
-/   .o+  -ooooosooooooosooooooo+//////////////////oooo- 
 oo.   +.
-/   .o+  -oooooooooooooooooooooooooooooooooooooooooooo- 
 oo.   +.
-/   .o+  -oooooooooooooooooooooooooooooooooooooooooooo- 
 oo.   +.
-+////o+` -oooo---:///:----://::------------------:oooo- 
`oo////+-
+ooooooo/`-oooo``:-```.:`.:.`.+/-    .::::::::::` .oooo-`+ooooooo+
oooooooo+`-oooo`-- `/` .:+  -/-`/`   .::::::::::  .oooo-.+oooooooo
+-/+://-/ -oooo-`:`.o-`:.:-````.:    .///:``````  -oooo-`/-//:+:-+
: :..--:-:.+ooo+/://o+/-.-:////:-....-::::-....--/+ooo+.:.:--.-- /
- /./`-:-` .:///+/ooooo/+///////////////+++ooooo/+///:. .-:.`+./ :
:-:/.           :`ooooo`/`              .:.ooooo :       
    ./---
                :`ooooo`/`              .:.ooooo :       
                :`ooooo./`              .:-ooooo :       
                :`ooooo./`              .:-ooooo :       
            `...:-+++++:/.              ./:+++++-:...`   
           :-.````````/../              /.-:````````.:-  
          -/::::::::://:/+             `+/:+::::::::::+. 
          :oooooooooooo++/              +++oooooooooooo- 

                           Webdriver.IO
              Next-gen browser and mobile automation     
                    test framework for Node.js


Installing @wdio/cli to initialize project...
 Success!
node:internal/modules/esm/resolve:214
  const resolvedOption = FSLegacyMainResolve(packageJsonUrlString, packageConfig.main, baseStringified);
                         ^

Error: Cannot find package 'C:\Users\nzaka\projects\humanwhocodes\fsx\packages\web\node_modules\@wdio\utils\node_modules\proxy-agent\package.json' imported from C:\Users\nzaka\projects\humanwhocodes\fsx\packages\web\node_modules\@wdio\utils\node_modules\@puppeteer\browsers\lib\esm\httpUtil.js
    at legacyMainResolve (node:internal/modules/esm/resolve:214:26)
    at packageResolve (node:internal/modules/esm/resolve:840:14)
    at moduleResolve (node:internal/modules/esm/resolve:910:20)
    at defaultResolve (node:internal/modules/esm/resolve:1130:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) 
{
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v20.11.0


⚠️  Ups, something went wrong: Error calling: npx wdio co
nfig!
npm ERR! code 1
npm ERR! path C:\Users\nzaka\projects\humanwhocodes\fsx\packages\web
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c create-wdio "."

npm ERR! A complete log of this run can be found in:     
npm ERR!     C:\Users\nzaka\AppData\Local\npm-cache\_logs\2024-01-24T00_21_30_109Z-debug.log


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Is there an existing issue for this?

- [X] I have searched the existing issues

[🐛 Bug]: wdio8 starter project is not working with typescript

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.0.9

Environment

  • OS Name: macOS Monterey (version 12.6.1)
  • System Model Name: MacBook Pro (16-inch, 2019)
  • npm: 7.6.3
  • Node.js: 13.14.0

Mode

Standalone Mode

Which capabilities are you using?

capabilities: [{
  maxInstances: 5,
  browserName: 'chrome',
  acceptInsecureCerts: true
}]

What happened?

Starting a new wdio project with typescript actually results in multiple errors.

I know that there is another opened issue that seems related #9334 but I needed a plain new issue to report all I've found and the corresponding fixes.

NB: I have no idea where to fix that in the code, nor time to submit a PR, so I let you guys decide what to do ;-)


After following the steps described in the How to reproduce the bug section and running the tests, here is what I have encountered:

Issue 1: Unexpected token 'export'

/Users/Badisi/Workspace/test-wdio/wdio.conf.ts:1
export const config = {
^^^^^^

SyntaxError: Unexpected token 'export'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1032:15)
    at Module._compile (node:internal/modules/cjs/loader:1067:27)
    at Module.m._compile (/Users/jpti/Workspace/test-wdio/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/jpti/Workspace/test-wdio/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:168:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:197:25)

Solution

This can be resolved by setting type:module in the package.json:

{
  "type": "module"
}

Issue 2: Cannot find module ... imported from ...

@wdio/runner: Error: Cannot find module '/Users/Badisi/Workspace/test-wdio/test/pageobjects/login.page' imported from /Users/Badisi/Workspace/test-wdio/test/specs/example.e2e.ts
[0-0]     at finalizeResolution (/Users/Badisi/Workspace/test-wdio/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:366:11)
[0-0]     at moduleResolve (/Users/Badisi/Workspace/test-wdio/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:801:10)
[0-0]     at Object.defaultResolve (/Users/Badisi/Workspace/test-wdio/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:912:11)
[0-0]     at /Users/Badisi/Workspace/test-wdio/node_modules/ts-node/src/esm.ts:218:35
[0-0]     at entrypointFallback (/Users/Badisi/Workspace/test-wdio/node_modules/ts-node/src/esm.ts:168:34)
[0-0]     at /Users/Badisi/Workspace/test-wdio/node_modules/ts-node/src/esm.ts:217:14
[0-0]     at addShortCircuitFlag (/Users/Badisi/Workspace/test-wdio/node_modules/ts-node/src/esm.ts:409:21)
[0-0]     at resolve (/Users/Badisi/Workspace/test-wdio/node_modules/ts-node/src/esm.ts:197:12)
[0-0]     at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
[0-0]     at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)

Solution

Looks like the issue comes from ts-node but instead comes from typescript.
Having set type:module in package.json now requires the relative import paths to have full extensions (see the blog post from Microsoft for more details).
So the solution is to put a .js extension at the end of these imports:

// test/pageobjects/login.page.ts
// test/pageobjects/login.page.ts
import Page from './page.js';

// test/specs/example.e2e.ts
import LoginPage from '../pageobjects/login.page.js';
import SecurePage from '../pageobjects/secure.page.js';

And now everything is working as expected!

What is your expected behavior?

No response

How to reproduce the bug.

  1. Create a new project using : npm init wdio@latest .
  2. Use the following answers:
    • Where should your tests be launched? -> local
    • Where is your automation backend located? -> On my local machine
    • Which framework do you want to use? -> Jasmine
    • Do you want to use a compiler? -> TypeScript
    • Do you want WebdriverIO to autogenerate some test files? -> Yes
    • Where should these files be located? -> accept defaults
    • Do you want to use page objects -> Yes
    • Where are your page objects located? -> accept defaults
    • Which reporter do you want to use? -> spec
    • Do you want to add a plugin to your test setup? -> none
    • Do you want to add a service to your test setup? -> chromedriver
    • What is the base url? -> accept defaults
    • Do you want me to run npm install -> Yes
  3. Start the tests with : npm run wdio

Relevant log output

-

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

[🐛 Bug]: bin/wdio clashes between packages wdio and @wdio/cli

As stated in the getting started guide:

To add a full WebdriverIO setup to an existing or new project, run:
$ npx wdio .

Issue

Actually this command can only be run once and not on an existing project (with wdio already installed), otherwise it crashes.

Ex: running npx wdio . twice results in the following error:

ERROR @wdio/config:ConfigParser: Failed loading configuration file: : Cannot find module

Explanation

On an empty project:
when npx wdio . is executed -> npm will download wdio package globally and run it.

On an existing project (with wdio already installed):
when npx wdio . is executed -> npm will use the local wdio available in node_modules/.bin but this one comes from the @wdio/cli package.

Add unit tests

I bootstrapped this project fairly quickly. We now need to make sure it is unit tested.

Couldn't initialise "@wdio/cucumber-framework"

I'm new to WebDriverIO. I followed the get started instructions at https://webdriver.io/docs/gettingstarted. However when I execute npm run wdio I see the following error message

[0-0] 2022-01-07T01:32:53.026Z ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't initialise "@wdio/cucumber-framework".
[0-0] Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/formatter/helpers/event_data_collector' is not defined by "exports" in /Users/stagr005/workspace/wdio-sample/node_modules/@cucumber/cucumber/package.json
[0-0]     at throwExportsNotFound (internal/modules/esm/resolve.js:285:9)
[0-0]     at packageExportsResolve (internal/modules/esm/resolve.js:491:3)
[0-0]     at resolveExports (internal/modules/cjs/loader.js:450:36)
[0-0]     at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
[0-0]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:27)
[0-0]     at Function.Module._load (internal/modules/cjs/loader.js:743:27)
[0-0]     at Module.require (internal/modules/cjs/loader.js:965:19)
[0-0]     at require (internal/modules/cjs/helpers.js:88:18)
[0-0]     at Object.<anonymous> (/Users/stagr005/workspace/wdio-sample/node_modules/@wdio/cucumber-framework/build/index.js:49:48)
[0-0]     at Module._compile (internal/modules/cjs/loader.js:1076:30)
[0-0]     at safeRequire (/Users/stagr005/workspace/wdio-sample/node_modules/@wdio/utils/build/utils.js:187:15)
[0-0]     at initialisePlugin (/Users/stagr005/workspace/wdio-sample/node_modules/@wdio/utils/build/initialisePlugin.js:30:50)
[0-0]     at Runner.run (/Users/stagr005/workspace/wdio-sample/node_modules/@wdio/runner/build/index.js:82:56)
[0-0]     at processTicksAndRejections (internal/process/task_queues.js:93:5)
[0-0] FAILED

I'm not sure how to resolve this. Any assistance would be appreciated

[🐛 Bug]: starter project generated with @wdio/cli does not run

WebdriverIO Version

7.16.3

Node.js Version

14.17.5

Mode

Standalone Mode

Which capabilities are you using?

No response

What happened?

The starter project generated with @wdio/cli does not run.

Following the getting started guide:

  1. Initiate a setup
npx wdio .

Screenshot 2021-11-02 at 11 26 24

  1. Run the test
npx wdio run ./wdio.conf.js

This outputs the following error:

Error: Could not execute "run" due to missing configuration. Would you like to create one? (y/N)

Issue

The issue here is that the wizard created a wdio.conf.ts and not a wdio.conf.js as stated in the doc (or as configured in the package.json script)

Attempt 1

Replacing the command with:

npx wdio run ./wdio.conf.ts

gives the following issue:

SyntaxError: Unexpected token 'export'

Workaround

Renaming wdio.conf.ts to wdio.conf.js and editing the file as follow:

// replace:
export const config: WebdriverIO.Config = {

// with:
exports.config = {

What is your expected behavior?

I expect the starter project to run without issues.

How to reproduce the bug.

Simply follow the getting started guide:

  1. Initiate a setup
npx wdio .
  1. Run the test
npx wdio run ./wdio.conf.js

Relevant log output

export const config: WebdriverIO.Config = {
^^^^^^

SyntaxError: Unexpected token 'export'
    at wrapSafe (internal/modules/cjs/loader.js:988:16)
    at Module._compile (internal/modules/cjs/loader.js:1036:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

thread absolute path as absolute path

If I run:

$ pwd
/some/other/dir
$ npm create wdio /tmp/foobar

I expect the project to be created in /tmp/foobar but instead it gets created in /some/other/dir/tmp/foobar.

Unable to open Allure report. Getting ERR_EMPTY_RESPONSE error.

Report generates fine on webdriverio. But when I run allure open
command, Getting ERR_EMPTY_RESPONSE error in all browsers like Chrome, Safari, Firefox. Tried different jdks, still cannot access allure report. Other people with same repo can access it, but I don't. Does anyone know how to fix that?

Screen Shot 2022-08-03 at 2 54 25 PM

Is yarn now a requirement?

A week or so ago, cloning a repo in my jenkins nightly run, started yelling for yarn to be installed.

+ BLAH_URL=http://172.17.0.4:3000 /ISOLATED_SELENIUM/run-tests.sh

Test Work DIR: /home/jenkins/worker/workspace/BLAH/nightly-selenium

> [email protected] test:jenkins /ISOLATED_SELENIUM

> wdio wdio.conf.js

-:...........................-:.

+ +

` '' + '...' '...' + ''

./+/ + .:://:::' '::///::' ' + ++/.

.+oo+ + /:+ooo+-/ /-+ooo+-/ ./ + +oo+.

-ooo+ + /-+ooo+-/ /-+ooo+-/ .: + +ooo.

-+o+ + '::///:-' '::///::' + +o+-

` ``. /. .: .```

.----------------------------.

'-::::::::::::::::::::::::::::::::::::::::-'

.+oooo/:------------------------------:/oooo+.

'.--/oooo- :oooo/--.'

.::-'':oooo' .oooo-''-::.

./-' -oooo'--.: :.-- .oooo- '-/.

-/' '-/oooo////////////////////////////////////oooo/.' '/-

+' '/+oooooooooooooooooooooooooooooooooooooooooooooooo+:' .+

-/ +o/.:oooooooooooooooooooooooooooooooooooooooooooo:-/o/ +.

-/ .o+ -oooosoooososssssooooo------------------:oooo- 'oo' +.

-/ .o+ -oooodooohyyssosshoooo' .oooo- oo. +.

-/ .o+ -oooodooysdooooooyyooo' '.--.'' .:::-oooo- oo. +.

-/ .o+ -oooodoyyodsoooooyyooo.//-..-:/:.'.//.'./oooo- oo. +.

-/ .o+ -oooohsyoooyysssysoooo+-' '-:::. .oooo- oo. +.

-/ .o+ -ooooosooooooosooooooo+//////////////////oooo- oo. +.

-/ .o+ -oooooooooooooooooooooooooooooooooooooooooooo- oo. +.

-/ .o+ -oooooooooooooooooooooooooooooooooooooooooooo- oo. +.

-+////o+' -oooo---:///:----://::------------------:oooo- 'oo////+-

+ooooooo/'-oooo'':-'''.:'.:.'.+/- .::::::::::' .oooo-'+ooooooo+

oooooooo+'-oooo'-- '/' .:+ -/-'/' .:::::::::: .oooo-.+oooooooo

+-/+://-/ -oooo-':'.o-':.:-''''.: .///:'''''' -oooo-'/-//:+:-+

: :..--:-:.+ooo+/://o+/-.-:////:-....-::::-....--/+ooo+.:.:--.-- /

- /./'-:-' .:///+/ooooo/+///////////////+++ooooo/+///:. .-:.'+./ :

:-:/. :'ooooo'/' .:.ooooo : ./---

` :'ooooo'/' .:.ooooo :'

:'ooooo./' .:-ooooo :

:'ooooo./' .:-ooooo :

'...:-+++++:/. ./:+++++-:...'

:-.''''''''/../ /.-:''''''''.:-

-/::::::::://:/+ '+/:+::::::::::+.

:oooooooooooo++/ +++oooooooooooo-

Webdriver.IO

Next-gen browser and mobile automation

                test framework for Node.js

events.js:291

throw er; // Unhandled 'error' event

^

Error: spawn yarnpkg ENOENT

at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)

at onErrorNT (internal/child_process.js:470:16)

at processTicksAndRejections (internal/process/task_queues.js:84:21)

Emitted 'error' event on ChildProcess instance at:

at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)

at onErrorNT (internal/child_process.js:470:16)

at processTicksAndRejections (internal/process/task_queues.js:84:21) {

errno: 'ENOENT',

code: 'ENOENT',

syscall: 'spawn yarnpkg',

path: 'yarnpkg',

spawnargs: [ '--version' ]

}

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! [email protected] test:jenkins: 'wdio wdio.conf.js'

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the [email protected] test:jenkins script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! /root/.npm/_logs/2021-09-02T08_06_12_087Z-debug.log

script returned exit code 1

I was able to continue testing after adding Yarn and create a Yarn.lock. This seems like a really bad Idea.

Please advise.

Running npm init wdio@latest ./e2e gives errors

This worked last night but when trying to setup a new framework by running the command given below tonight, it is giving errors

Command to Run : npm init wdio@latest ./e2e

Output of the command:

Need to install the following packages:
[email protected]
Ok to proceed? (y) y

             -:...........................-:.
             +                              +
          `` +      `...`        `...`      + `
        ./+/ +    .:://:::`    `::///::`  ` + ++/.
       .+oo+ +    /:+ooo+-/    /-+ooo+-/ ./ + +oo+.
       -ooo+ +    /-+ooo+-/    /-+ooo+-/ .: + +ooo.
        -+o+ +    `::///:-`    `::///::`    + +o+-
         ``. /.     `````        `````     .: .``
              .----------------------------.
       `-::::::::::::::::::::::::::::::::::::::::-`
      .+oooo/:------------------------------:/oooo+.
  `.--/oooo-                                  :oooo/--.`
.::-``:oooo`                                  .oooo-``-::.

./- -oooo--.: :.-- .oooo- -/. -/ -/oooo////////////////////////////////////oooo/. /- + /+oooooooooooooooooooooooooooooooooooooooooooooooo+: .+
-/ +o/.:oooooooooooooooooooooooooooooooooooooooooooo:-/o/ +.
-/ .o+ -oooosoooososssssooooo------------------:oooo- oo +.
-/ .o+ -oooodooohyyssosshoooo .oooo- oo. +. -/ .o+ -oooodooysdooooooyyooo .--.`` .:::-oooo- oo. +. -/ .o+ -oooodoyyodsoooooyyooo.//-..-:/:..//../oooo- oo. +. -/ .o+ -oooohsyoooyysssysoooo+- -:::. .oooo- oo. +. -/ .o+ -ooooosooooooosooooooo+//////////////////oooo- oo. +. -/ .o+ -oooooooooooooooooooooooooooooooooooooooooooo- oo. +. -/ .o+ -oooooooooooooooooooooooooooooooooooooooooooo- oo. +. -+////o+ -oooo---:///:----://::------------------:oooo- oo////+- +ooooooo/-oooo``:-```.:.:..+/- .::::::::::` .oooo-`+ooooooo+
oooooooo+`-oooo`-- `/` .:+ -/-`/` .:::::::::: .oooo-.+oooooooo
+-/+://-/ -oooo-`:`.o-`:.:-````.: .///:`````` -oooo-`/-//:+:-+
: :..--:-:.+ooo+/://o+/-.-:////:-....-::::-....--/+ooo+.:.:--.-- /

  • /./-:- .:///+/ooooo/+///////////////+++ooooo/+///:. .-:.+./ : :-:/. :ooooo/ .:.ooooo : ./---
    :ooooo/ .:.ooooo : :ooooo./ .:-ooooo : :ooooo./ .:-ooooo :...:-+++++:/. ./:+++++-:...:-.````````/../ /.-:````````.:- -/::::::::://:/+ +/:+::::::::::+.
    :oooooooooooo++/ +++oooooooooooo-

                         Webdriver.IO
            Next-gen browser and mobile automation
                  test framework for Node.js
    

Installing @wdio/cli to initialize project...
✔ Success!

===============================
🤖 WDIO Configuration Wizard 🧙

? What type of testing would you like to do? E2E Testing - of Web or Mobile Applications
? Where is your automation backend located? On my local machine
? Which environment you would like to automate? Web - web applications in the browser
? With which browser should we start? Chrome
? Which framework do you want to use? Cucumber (https://cucumber.io/)
? Do you want to use a compiler? TypeScript (https://www.typescriptlang.org/)
? Do you want WebdriverIO to autogenerate some test files? Yes
? Where should these feature files be located? C:\Projects\SourceTrials\wdtests\e2e\features**.feature
? Where should these step definitions be located? C:\Projects\SourceTrials\wdtests\e2e\features\step-definitions\steps.ts
? Do you want to use page objects (https://martinfowler.com/bliki/PageObject.html)? Yes
? Where are your page objects located? C:\Projects\SourceTrials\wdtests\e2e\features\pageobjects*
*.ts
? Which reporter do you want to use? spec
? Do you want to add a plugin to your test setup?
? Do you want to add a service to your test setup? chromedriver
? What is the base url? http://localhost
? Do you want me to run npm install Yes

Setting up TypeScript...
✔ Success!

Installing wdio packages:

  • @wdio/local-runner@latest
  • @wdio/cucumber-framework@latest
  • @wdio/spec-reporter@latest
  • wdio-chromedriver-service
  • ts-node
  • typescript
  • chromedriver

added 159 packages, and audited 612 packages in 31s

88 packages are looking for funding
run npm fund for details

9 moderate severity vulnerabilities

To address all issues (including breaking changes), run:
npm audit fix --force

Run npm audit for details.
✔ Success!

Creating a WebdriverIO config file...
✔ Success!

Autogenerating test files...
wdio.js config

Initialize WebdriverIO and setup configuration in your current project.

Options:
--version Show version number [boolean]
--watch Run WebdriverIO in watch mode [boolean]
-h, --hostname automation driver host address [string]
-p, --port automation driver port [number]
--path path to WebDriver endpoints (default "/") [string]
-u, --user username if using a cloud service as automation backend
[string]
-k, --key corresponding access key to the user [string]
-l, --logLevel level of logging verbosity
[choices: "trace", "debug", "info", "warn", "error", "silent"]
--bail stop test runner after specific amount of tests have fa
iled [number]
--baseUrl shorten url command calls by setting a base url[string]
-w, --waitforTimeout timeout for all waitForXXX commands [number]
-f, --framework defines the framework (Mocha, Jasmine or Cucumber) to r
un the specs [string]
-r, --reporters reporters to print out the results on stdout [array]
--suite overwrites the specs attribute and runs the defined sui
te [array]
--spec run only a certain spec file - overrides specs piped fr
om stdin [array]
--exclude exclude certain spec file from the test run - overrides
exclude piped from stdin [array]
--multi-run Run individual spec files x amount of times [number]
--mochaOpts Mocha options
--jasmineOpts Jasmine options
--cucumberOpts Cucumber options
--autoCompileOpts Auto compilation options
--coverage Enable coverage for browser runner
--yarn Install packages via Yarn package manager.
[boolean] [default: false]
-y, --yes will fill in all config defaults without prompting
[boolean] [default: false]
-t, --npmTag define NPM tag to use for WebdriverIO related packages
[string] [default: "latest"]
--help Show help [boolean]

Documentation: https://webdriver.io
@wdio/cli (v8.12.1)

Error: ⚠️ Couldn't write config file: ReferenceError: C:\Projects\SourceTrials\wdtests\e2e\node_modules@wdio\cli\build\templates\exampleFiles\cucumber\step_definitions\steps.js.ejs:9
7| */
8| if (answers.usePageObjects) { %>

9| <%- answers.isUsingTypeScript || answers.esmSupport
10| ? import LoginPage from '${relativePath}/login.page${answers.esmSupport ? '.js' : ''}';
11| : const LoginPage = require('${relativePath}/login.page'); %>
12| <%- answers.isUsingTypeScript || answers.esmSupport

relativePath is not defined
at eval ("C:\Projects\SourceTrials\wdtests\e2e\node_modules\@wdio\cli\build\templates\exampleFiles\cucumber\step_definitions\steps.js.ejs":25:33)
at steps.js (C:\Projects\SourceTrials\wdtests\e2e\node_modules\ejs\lib\ejs.js:703:17)
at tryHandleCache (C:\Projects\SourceTrials\wdtests\e2e\node_modules\ejs\lib\ejs.js:274:36)
at exports.renderFile (C:\Projects\SourceTrials\wdtests\e2e\node_modules\ejs\lib\ejs.js:491:10)
at node:internal/util:375:7
at new Promise ()
at node:internal/util:361:12
at generateLocalRunnerTestFiles (file:///C:/Projects/SourceTrials/wdtests/e2e/node_modules/@wdio/cli/build/utils.js:369:35)
at async createWDIOConfig (file:///C:/Projects/SourceTrials/wdtests/e2e/node_modules/@wdio/cli/build/utils.js:730:13)
at async runConfigCommand (file:///C:/Projects/SourceTrials/wdtests/e2e/node_modules/@wdio/cli/build/commands/config.js:119:5)
at createWDIOConfig (file:///C:/Projects/SourceTrials/wdtests/e2e/node_modules/@wdio/cli/build/utils.js:735:15)
at async runConfigCommand (file:///C:/Projects/SourceTrials/wdtests/e2e/node_modules/@wdio/cli/build/commands/config.js:119:5)
at async Object.handler (file:///C:/Projects/SourceTrials/wdtests/e2e/node_modules/@wdio/cli/build/commands/config.js:129:5)

⚠️ Ups, something went wrong: Error calling: npx wdio config!
npm ERR! code 1
npm ERR! path C:\Projects\SourceTrials\wdtests
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c create-wdio ./e2e

npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\v\AppData\Local\npm-cache_logs\2023-07-10T13_32_20_639Z-debug-0.log

Not entirely sure what the problem is or what change to cause this error. Any help would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.