Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[🐛 Bug]: webdriverio's expect not working with node 16 #8219

Closed
3 tasks done
Badisi opened this issue Apr 14, 2022 · 9 comments
Closed
3 tasks done

[🐛 Bug]: webdriverio's expect not working with node 16 #8219

Badisi opened this issue Apr 14, 2022 · 9 comments
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested

Comments

@Badisi
Copy link
Contributor

Badisi commented Apr 14, 2022

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

7.19.5

Node.js Version

16.14.2

Mode

WDIO Testrunner

Which capabilities are you using?

{
  browserName: 'chrome',
  maxInstances: 5,
  acceptInsecureCerts: true
}

What happened?

The following code is working fine on node12, node14 but not on node16 :

describe('Test', () => {
  beforeEach(async () => {
    await browser.url('http://localhost:4200');
  });
  it('Button should be displayed', async () => {
    const buttonEl = $('button');
    await expect(buttonEl).toBeDisplayed();
  });
});
# With node16:
Error: Expected [object Promise] to be displayed.
    at <Jasmine>
    at /Users/Badisi/tests-e2e/index.e2e.ts:18:33
    at step (/Users/tests-e2e/index.e2e.ts:33:23)
    at Object.next (/Users/Badisi/tests-e2e/index.e2e.ts:14:53)

A possible workaround is :

describe('Test', () => {
  beforeEach(async () => {
    require('expect-webdriverio');
    global.wdioExpect = global.expect;
    const jasmine = require('jasmine');
    global.expect = jasmine.expect;

    await browser.url('http://localhost:4200');
  });
  it('Button should be displayed', async () => {
    const buttonEl = $('button');
    await global.wdioExpect(buttonEl).toBeDisplayed();
  });
});

It's obvious that this has to do with expect-webdriverio and jasmine but I don't know exactly where the problem is.

Any advices on how I should handle this ? Is the workaround legit or is it simply a bug that needs to be fixed ?

Thanks!

What is your expected behavior?

No response

How to reproduce the bug.

Run the example, provided in the "What happened?" section above, in a node16 environment.

Relevant log output

Error: Expected [object Promise] to be displayed.
    at <Jasmine>
    at /Users/Badisi/tests-e2e/index.e2e.ts:18:33
    at step (/Users/tests-e2e/index.e2e.ts:33:23)
    at Object.next (/Users/Badisi/tests-e2e/index.e2e.ts:14:53)

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
@Badisi Badisi added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels Apr 14, 2022
@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested and removed Needs Triaging ⏳ No one has looked into the issue yet labels Apr 14, 2022
@christian-bromann
Copy link
Member

Thanks for reporting!

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!

@Badisi
Copy link
Contributor Author

Badisi commented Apr 14, 2022

Thanks @christian-bromann.

Like I said in the description, it is obvious that this has to do with expect-webdriverio and jasmine but I don't know exactly where the problem is and I'm not too familiar with one or the other.

Do you have any guidances ?

@christian-bromann
Copy link
Member

Do you have any guidances ?

I think you are pointing into the right direction. I have the same guess.

@bburggraff
Copy link

@christian-bromann @Badisi - I'm encountering the same issue as well. I think it was introduced as part of #8175.

Is it as simple as changing this to expectAsync instead of expectSync?
https://github.com/webdriverio/webdriverio/blob/main/packages/wdio-utils/src/shim.ts#L421

@christian-bromann
Copy link
Member

@bburggraff mind raising a PR with a test for this?

@bburggraff
Copy link

Sorry @christian-bromann , I just am getting back to this. It looks like it's being addressed as part of #8278

@christian-bromann
Copy link
Member

@bburggraff that PR just reverts the patch that has introduced this bug trying to patch another bug. I would prefer to have a fix for this so we don't have to revert things.

@bburggraff
Copy link

@bburggraff that PR just reverts the patch that has introduced this bug trying to patch another bug. I would prefer to have a fix for this so we don't have to revert things.

I see.

I'm not super familiar with the code base, but I'll try to look into this.

@christian-bromann
Copy link
Member

fixed in #8300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested
Projects
None yet
Development

No branches or pull requests

3 participants