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

chore: add eslint-plugin-jest's valid-expect rule #16332

Merged
merged 2 commits into from
Aug 14, 2019

Conversation

SimenB
Copy link
Contributor

@SimenB SimenB commented Aug 9, 2019

There are some assertions here which just do expect(thing) without a matcher, meaning it's not actually asserting anything (it does not work like assert). I added .toBe(true) to them, and 2 of the tests are failing, meaning they are either wrong, or false negatives on master.

The above is dated now that #16336 was merged, but it did uncover them 🙂

@sizebot
Copy link

sizebot commented Aug 9, 2019

No significant bundle size changes to report.

Generated by 🚫 dangerJS

expect(toHaveAttribute(genMarkup({className: 'a'}), ['class', 'a']));
expect(toHaveAttribute(genMarkup({className: 'a b'}), ['class', 'a b']));
expect(toHaveAttribute(genMarkup({className: ''}), ['class', '']));
expect(toHaveAttribute(genMarkup({className: 'a'}), ['class', 'a'])).toBe(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really related to this PR, but toHaveAttribute should probably be written as a custom matcher rather than a function which returns a boolean.

threepointone added a commit to threepointone/react that referenced this pull request Aug 9, 2019
These were discovered by @SimenB in facebook#16332. We weren't making actual assertions on some values. This PR makes the assertions, and fixes the tests.
threepointone added a commit to threepointone/react that referenced this pull request Aug 9, 2019
These were discovered by @SimenB in facebook#16332. We weren't making actual assertions on some values. This PR makes the assertions, and fixes the tests.
@threepointone
Copy link
Contributor

Feel free to rebase from master, the fixes have landed

threepointone pushed a commit that referenced this pull request Aug 9, 2019
These were discovered by @SimenB in #16332. We weren't making actual assertions on some values. This PR makes the assertions, and fixes the tests.
@SimenB
Copy link
Contributor Author

SimenB commented Aug 9, 2019

Awesome, thanks for dealing with it!

@gaearon
Copy link
Collaborator

gaearon commented Aug 13, 2019

Oops, this still needs a merge, sorry

@SimenB
Copy link
Contributor Author

SimenB commented Aug 13, 2019

rebased

@threepointone threepointone merged commit 5fa99b5 into facebook:master Aug 14, 2019
@SimenB SimenB deleted the eslint-jest-valid-expect branch August 14, 2019 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants