Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
3 tasks done
MortenGregersen opened this issue Jan 12, 2022 · 2 comments
Closed
3 tasks done
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@MortenGregersen
Copy link

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
@christian-bromann christian-bromann transferred this issue from webdriverio/webdriverio Jan 12, 2022
@christian-bromann
Copy link
Member

Thanks for reporting!

It seems there is a problem detecting TypeScript correctly somewhere here: https://github.com/webdriverio/create-wdio/blob/main/src/index.ts#L110

Any contributions that resolves the bug are highly appreciated. Please take a look into our contribution guidelines and let us know if you have any questions. Cheers!

@christian-bromann christian-bromann added bug Something isn't working help wanted Extra attention is needed labels Jan 12, 2022
@christian-bromann
Copy link
Member

fixed in #86, thanks @vigneshmohan243 👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants