I have the following function which fails on execution:
it('should show three items', () => {
const EXPECTED_NUMBER_OF_ITEMS: number = 3;
const countOfTabElements: Promise<number> = page.listOfTabs.count();
expect(countOfTabElements).toBe(EXPECTED_NUMBER_OF_ITEMS);
});
It throws the following Error when i execute it:
Argument of type 'number' is not assignable to parameter of type 'Expected>'. (2345)
Any ideas why?
Alternatively to @Nitzan Tomer answer you should be able to use async/await (TS >= 2.1 for targeting ES5)
it('should show three items', async () => {
const EXPECTED_NUMBER_OF_ITEMS: number = 3;
const value = await page.listOfTabs.count();
expect(value).toBe(EXPECTED_NUMBER_OF_ITEMS);
});
(as a side note I believe you need a fairly recent version of Mocha to handle promise rejection correctly)
Try:
it('should show three items', () => {
const EXPECTED_NUMBER_OF_ITEMS: number = 3;
page.listOfTabs.count().then(value => {
expect(value).toBe(EXPECTED_NUMBER_OF_ITEMS);
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With