Skip to content

The support for worlds in TypeScript did not extend to the IStepHookBody interface #1304

@fedetibaldo

Description

@fedetibaldo

Current behavior

interface CustomWorld extends Mocha.Context {
  title: string;
}

AfterStep({ name: 'I am on the "Main" page' }, function(this: CustomWorld) {
  this.title = "read from page";
});

will raise

Argument of type '(this: CustomWorld) => void' is not assignable to parameter of type 'IStepHookBody'.
  The 'this' types of each signature are incompatible.

Desired behavior

The wish, as previously expressed by #864, is to be able to work with custom worlds by providing a this type to hook functions that extends Mocha.Context.

Cypress version

14.3.2

Preprocessor version

22.0.1

Node version

v22.15.0

Operating system

MacOS

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions