webdriverio / expect-webdriverio

WebdriverIO Assertion Library
https://webdriver.io
MIT License
75 stars 52 forks source link

[🐛 Bug]: Not able to use arrayContaining, stringContaining on expect #1332

Closed yach01 closed 11 months ago

yach01 commented 1 year ago

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.18.2

Node.js Version

18.18.1

Mode

WDIO Testrunner

Which capabilities are you using?

{
        'browserName': 'chrome',
        'goog:chromeOptions': {
            args: [
                '--disable-infobars',
                '--log-level=ALL',
                ...!args.getHeadless() ? [] : [
                    '--headless',
                    '--disable-gpu',
                    '--window-size=1920,1080',
                ],
            ],
        },
        'acceptInsecureCerts': true
    }

What happened?

I upgrade my project from v7 to v8. In v7 its working fine. But not working in v8. When try to use this expect(arrayIds).toEqual(expect.arrayContaining(['123'])); expect('text').toEqual(expect.stringContaining('text'));

Then getting following error: TypeError: expect.arrayContaining is not a function Same for stringContaining method.

What is your expected behavior?

As in v7, it should work in v8 as well, as we have same method in standalone.d.ts.

If not then there should be an explanation for how to replace this.

How to reproduce the bug.

You can simply create a new project using following command npm init wdio ./path/to/new/project

Then select following options ? 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 ? What should be the location of your feature files? D:\Desktop\Betsson\webdriverio-demo\demo\features**.feature ? What should be the location of your step definitions? D:\Desktop\Betsson\webdriverio-demo\demo\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? D:\Desktop\Betsson\webdriverio-demo\demo\features\pageobjects**.ts ? Which reporter do you want to use? spec, dot ? Do you want to add a plugin to your test setup? ? Do you want to add a service to your test setup? ? What is the base url? http://localhost:4000 ? Do you want me to run npm install Yes

And try to use expect.stringContaining/arrayContaining method.

Relevant log output

TypeError: expect.stringContaining is not a function
[chrome 118.0.5993.71 windows #0-0] TypeError: expect.stringContaining is not a function
[chrome 118.0.5993.71 windows #0-0]     at World.<anonymous> (file:///webdriverio-demo/demo/features/step-definitions/steps.ts:20:12)

Code of Conduct

Is there an existing issue for this?

christian-bromann commented 1 year ago

As in v7, it should work in v8 as well

I don't think it ever worked in v7 either using Cucumber. These special matchers only work when using Jasmine

as we have same method in standalone.d.ts.

I am not sure what your standalone.d.ts is

Anyway, I think we should make this behavior consistent in v8.

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

yach01 commented 1 year ago

standalone.d.ts, you can find this here: node_modules\expect-webdriverio\types\standalone.d.ts And as per this file we have these methods, and able to use in v7. But now its not working.