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

WaitFor can't be awaited in TS #2

Closed
NaZaRKIN123 opened this issue Oct 16, 2024 · 4 comments
Closed

WaitFor can't be awaited in TS #2

NaZaRKIN123 opened this issue Oct 16, 2024 · 4 comments
Labels

Comments

@NaZaRKIN123
Copy link

NaZaRKIN123 commented Oct 16, 2024

Hello,

I'm trying to use this plugin with TS but not sure what is missing. So bindWaitFor returns the chai assertion but not the promise. So I'm getting an error: "'await' has no effect on the type of this expression.ts(80007)"
Also when it's not awaited it always pass, it doesn't matter what the inputs are.

Can you help to fix it?

My code example:

import { Then } from '@cucumber/cucumber'
import { use } from 'chai'
import chai_wait_for, { bindWaitFor } from 'chai-wait-for'

use(chai_wait_for)
const waitFor = bindWaitFor({
  timeout: 5000,
  retryInterval: 300,
})

Then(/test/, () => {
  const myObj = { foo: 0 }

  setInterval(() => myObj.foo++, 1000)

  // Then use it just like you would expect() (but note you must await it!)
  await waitFor(myObj).to.have.property('foo').that.equals(3)
})
@jedwards1211
Copy link
Member

Yeah I'll have to spend some time investigating this, having waitFor return a Chai.PromisedAssertion (defined by chai-as-promised) works, but I need to figure out what to do if you aren't using chai-as-promised (because it adds language chains to the TS defs that won't be present at runtime if you aren't adding the chai-as-promised plugin)

@jedwards1211
Copy link
Member

🎉 This issue has been resolved in version 2.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jedwards1211
Copy link
Member

Cheers, let me know if you still have problems with the 2.0.3 release

@NaZaRKIN123
Copy link
Author

Hello @jedwards1211 , the error is gone and no await is needed. Thanks! But it still always pass. I'll open another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants