-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
chore(lint): use jest/prefer-to-have-length
rule
#13370
chore(lint): use jest/prefer-to-have-length
rule
#13370
Conversation
@@ -349,7 +349,7 @@ jest.mock('./sound-player', () => { | |||
}); | |||
``` | |||
|
|||
This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toBe(1);` | |||
This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toBeGreaterThan(0);` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -167,6 +167,8 @@ module.exports = { | |||
'jest/no-focused-tests': 'error', | |||
'jest/no-identical-title': 'error', | |||
'jest/prefer-to-be': 'error', | |||
'jest/prefer-to-contain': 'error', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jest/prefer-to-contain
is added for completeness. It did not find any errors, but that is not yet enough to use extends: ['plugin:jest/style']
.
expect(importedFn.mock.calls.length).toBe(1); | ||
expect(localFn.mock.calls.length).toBe(1); | ||
expect(importedFn).toHaveBeenCalledTimes(1); | ||
expect(localFn).toHaveBeenCalledTimes(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were reworked manually (here and in other files).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Also
jest/prefer-to-have-length
rule could be added to ESLint config. Quick search shows that currentlytoHaveLength
matcher is used 81 time in 36 files (excluding*.md
). Let’s add few more?Test plan
Green CI.