-
Notifications
You must be signed in to change notification settings - Fork 15
getByRole expecting incorrect parameters #22
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
Comments
To add to this, if I instead use
Then this has exactly the same errors, so I don't think it's anything to do with having done Also, the code works fine. If I make it:
then it builds and runs perfectly fine. So it's not the code but the typing that I'm struggling with. Cheers |
Even more curious, I've just written a tiny bit of code using
This builds perfectly well with tsc, unsurprisingly. But Cmnd-clicking on the |
And just like that - I've got a fix :) Apparently, my Well score one for a solution :) I'm leaving this open just in case you feel it's worth adding any docs, but feel free to close it since I've got things working now. Cheers |
Hi 👋 Thanks for raising this, we should definitely update the docs to include a note in the Typescript section so this is clear for anybody finding the same! I'm going to keep this issue open until we have updated the docs 😄 I spent some time digging into why this happens so I could to be certain of the root cause and fix it if it's something to do with webdriverio-testing-library: Under the hood I used the types from dom-testing-library to create the types for webdriverio-testing-library, this was so that the available parameters and options would match dom-testing-library queries, but the return values would always be a Promise and use the dom-testing-library assumes that the dom lib is included globally as it uses the When the dom types aren't included then type BoundGetByRole = BoundFunction<GetByRole>
// BoundGetByRole is (text: ByRoleOptions | undefined, options?: unknown) => any Anyways I thought it was interesting, but none of this really matters as you have already got the solution! 😝 |
WebdriverIO Testing Library assumes that users include the DOM types in their typescript default types. Add a note to the Typescript section of the WTL docs to help users who are finding type errors when they haven't. Related issue: testing-library/webdriverio-testing-library#22
WebdriverIO Testing Library assumes that users include the DOM types in their typescript default types. Add a note to the Typescript section of the WTL docs to help users who are finding type errors when they haven't. Related issue: testing-library/webdriverio-testing-library#22
The update to the docs has been merged 🎉 Thanks again for raising this and using the lib! Please don't hesitate to raise any other issues you find 😄 |
I'm assuming that I'm doing something wrong here, but I can't work out what. :(
I've just converted my (fledgling) WebdriverIO E2E tests from JavaScript to TypeScript, and the places that I'm calling testing-library functions are complaining in a strange way.
For example, I've got:
And then tsc complains with:
However, I can't see why this is happening.
getByRole
is meant to take two parameters, of whichByRoleOptions | undefined
is the second one, and'navigation'
is perfectly valid for what is meant to be the first parameter.I've defined this module in my code:
This means that the functions themselves are found, but all seem to be expecting only the final parameter instead of the correct ones.
Have I missed something obvious? If so, what? :)
Cheers
The text was updated successfully, but these errors were encountered: