-
Notifications
You must be signed in to change notification settings - Fork 40
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
Ability to further extend expect-expect to match any function/method name #316
Comments
I think what would be best is to simply add support for member expressions (e.g. |
Using Would it be possible to automatically detect when a helper function contains a expect statement?
|
@maxime-dupuis I really like that idea a lot. It won't be perfect semantic analysis (e.g. if you import a helper, it won't work), but could be really nice for the majority of single file uses. |
Hi @mskelton, I'm wondering why supporting regex is discouraged. In my use case, I would like configure the lint rule to consider any helper functions that starts with |
@slhsxcmy Hmm, you make a fair point, perhaps regex is the way to go. I would say then we should do the following:
|
Pretty much an extension of this issue.
We use a sort of scrappy version of the Screenplay pattern, basically just an abstract base class for common testing logic and child classes for each user bucket. Thus many of our assertions live inside a class method:
Thus from inside the spec it looks like:
I tried specifying the allowed methods like this but that didn't work and the rule still reported an error:
I could probably work around this by assigning the class methods like so (untested):
What would help our use case and keep our code clean is if we could specify a further property of the eslint rule that, rather than looking for an exact function name or call signature, simply checks that the method name matches a specific character sequence:
This rule would enable functions in any form and in any call/execution context to work so long as the name and location logic match, the advantage being that it is agnostic about where the function/method comes from. For example the above config would allow for:
Shorthand could default match logic to contains:
I'm flexible on the schema - if there's a more eslint/PlayWright friendly way to structure the rule options then happy with that, mainly concerned about the logic.
If this sounds like an acceptable suggestion and in line with the plugin I would be happy to open a PR that adds it in due time 👍🏽
The text was updated successfully, but these errors were encountered: