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

valid-describe-callback reports false positive with named function #339

Open
msorens opened this issue Dec 20, 2024 · 3 comments
Open

valid-describe-callback reports false positive with named function #339

msorens opened this issue Dec 20, 2024 · 3 comments

Comments

@msorens
Copy link

msorens commented Dec 20, 2024

I have a function that runs a block of tests and I use this function in a couple places, so I have it encapsulated as a first-class function rather than inlined, as is typical. The function is a valid callback meeting the criteria specified by the rule:

  • should not be async
  • should not contain any parameters
  • should not contain any return statements

Minimal test case:

function foo() {
  test('create policies', async ({ system, page }) => {})
}
test.describe('policies', foo)

The describe line is flagged as a violation because the function is not inlined. Would be nice if the plugin could recognize this case.

@mskelton
Copy link
Member

Why would you ever need to write tests like this?

@msorens
Copy link
Author

msorens commented Dec 22, 2024

Please re-read my first sentence; it is something I use in more than one place. But that question is moot; the way I wrote that code is valid and the plugin should not claim it is invalid.

@mskelton
Copy link
Member

I did read it. There is just not scenario where that would make sense. It is not at all wrong for the plugin to complain about code that is poorly written. That's a hill I will die on. There are tons of scenarios that do not make sense that are "technically" valid, it does not mean I'm going to support them in the plugin.

Why aren't you using parameterized tests if you need to use a common test function? https://playwright.dev/docs/test-parameterize

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

No branches or pull requests

2 participants