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

The prefer-to-have-count rule does not deference expect arguments to verify their assigned value. #293

Closed
An631 opened this issue May 16, 2024 · 0 comments

Comments

@An631
Copy link
Contributor

An631 commented May 16, 2024

The current prefer-to-have-count rule has a problem where any expect checks that take a variable argument will not check to make sure the value is not originating from a .count call.

For example the following code would not be flagged as an error:

   const filesCount = await files.count();
   expect(filesCount).toBe(2);

The current code misses this case because we are not dereferencing the last assigned value of filesCount at the moment of verifying the expect argument. The rule should flag the error and return the following as a fix:

   const filesCount = files;
   await expect(filesCount).toHaveCount(2);
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