ui5-typescript icon indicating copy to clipboard operation
ui5-typescript copied to clipboard

`@sapui5/ts-types-esm` - `PageObjectDefinition.actions` & `assertions` function types should have a `this` parameter

Open DetachHead opened this issue 4 years ago • 1 comments

export type PageObjectDefinition = {
    //...
    actions?: Record<string, (this: Opa5) => void>;
    assertions?: Record<string, (this: Opa5) => void>;
}

otherwise this example won't compile bcause the this type is not defined:

Opa5.createPageObjects({
    onTheAppPage: {
        actions: {},

        assertions: {
            iShouldSeeTheApp: function () {
                // error: Cannot invoke an object which is possibly 'undefined'
                this.waitFor({
                    id: 'myButton',
                    actions: function () {},
                    success: function () {},
                })
            },
        },
    },
})

DetachHead avatar Nov 25 '21 02:11 DetachHead

Same like #306 - testing related code wasn't in focus of TS API support so far.

petermuessig avatar Nov 28 '21 16:11 petermuessig