Description
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:
export class BasePage {
get header() {
return browser.getByRole('navigation').then((element) => new HeaderBar(element));
}
}
And then tsc complains with:
$ tsc
src/pageobjects/base/index.ts:11:30 - error TS2345: Argument of type '"navigation"' is not assignable to parameter of type 'ByRoleOptions | undefined'.
11 return browser.getByRole('navigation').then((element) => new HeaderBar(element));
However, I can't see why this is happening. getByRole
is meant to take two parameters, of which ByRoleOptions | 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:
import { WebdriverIOQueries } from '@testing-library/webdriverio';
declare global {
namespace WebdriverIO {
interface Browser extends WebdriverIOQueries {}
interface Element extends WebdriverIOQueries {}
}
}
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