Skip to content
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

Update Locator.build typing to have locator parameter be optional #4542

Closed
silvanusbuyesti opened this issue Nov 6, 2024 · 0 comments · Fixed by #4543
Closed

Update Locator.build typing to have locator parameter be optional #4542

silvanusbuyesti opened this issue Nov 6, 2024 · 0 comments · Fixed by #4543

Comments

@silvanusbuyesti
Copy link

What are you trying to achieve?

When using AI to generate Page Objects, it generates a number of them that start with simply locate() with no parameter passed.

According to the code, this is completely valid:
Locator.build = (locator) => { if (!locator) return new Locator({ xpath: '//*' }); return new Locator(locator, 'css'); };

Typescript is upset there is nothing passed as the type is defined as:
static build(locator: CodeceptJS.LocatorOrString): Locator;

Since the actual function doesn't care about having a 'locator' actually passed, this should be set to optional.
static build(locator?: CodeceptJS.LocatorOrString): Locator;

Details

  • CodeceptJS version: 3.6.7
  • NodeJS Version:22.2.0
  • Operating System: Mac

Workaround

Add a locator parameter to the locate call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant