Skip to content

[🐛 Bug]: Missing type information for expect, $ and $$ when initialized for Cucumber #13900

@htho

Description

@htho

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.2.14

Node.js Version

v20.15.1

Mode

WDIO Testrunner

Which capabilities are you using?

No response

What happened?

When I run npm init wdio@8.4.10 ./ReproCucumber and configure the project with Cucumber and Typescript, type information is missing.

When I open features\step-definitions\steps.ts and inspect await expect(SecurePage.flashAlert).toBeExisting(); then there are no type Information for expect.toBeExisting.

In features\pageobjects\login.page.ts the type of $ is any.

When I look at the definitions in node_modules\@wdio\globals\build\index.d.ts and the line export declare const $: WebdriverIO.Browser['$']; then there is an error: Property '$' does not exist on type 'Browser'.ts(2339)
The same for the next line ($$)
And for the next line: export declare const expect: ExpectWebdriverIO.Expect; the error is Cannot find namespace 'ExpectWebdriverIO'.ts(2503)

When I run npm init wdio@8.4.10 ./ReproMocha and configure the project with Mocha and Typescript all type information are available as expected.

What is your expected behavior?

The type information should be available.

How to reproduce the bug.

This initializes a broken project:
npm init wdio@8.4.10 ./ReproCucumber

√ A project named "ReproCucumber" was detected at "C:\dev\ReproCucumber", correct? yes
√ 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 Typescript to write tests? yes
√ Do you want WebdriverIO to autogenerate some test files? yes
√ What should be the location of your feature files? C:\dev\ReproCucumber\features\**\*.feature
√ What should be the location of your step definitions? C:\dev\ReproCucumber\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:\dev\ReproCucumber\features\pageobjects\**\*.ts
√ Which reporter do you want to use?
√ Do you want to add a plugin to your test setup?
√ Would you like to include Visual Testing to your setup? For more information see https://webdriver.io/docs/visual-testing! no
√ Do you want to add a service to your test setup?
√ Do you want me to run `npm install` yes

This initializes a working project:
npm init wdio@8.4.10 ./ReproMocha

√ A project named "ReproMocha" was detected at "C:\dev\ReproMocha", correct? yes
√ 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? Mocha (https://mochajs.org/)
√ Do you want to use Typescript to write tests? yes
√ Do you want WebdriverIO to autogenerate some test files? yes
√ What should be the location of your spec files? C:\dev\ReproMocha\test\specs\**\*.ts
√ Do you want to use page objects (https://martinfowler.com/bliki/PageObject.html)? yes
√ Where are your page objects located? C:\dev\ReproMocha\test\pageobjects\**\*.ts
√ Which reporter do you want to use?
√ Do you want to add a plugin to your test setup?
√ Would you like to include Visual Testing to your setup? For more information see https://webdriver.io/docs/visual-testing! no
√ Do you want to add a service to your test setup?
√ Do you want me to run `npm install` yes

Relevant log output

see the output from above

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions