-
Notifications
You must be signed in to change notification settings - Fork 71
Closed
Labels
Description
I see quite a few instances of test code that looks like this:
expect(getByText('report'));
expect(getByRole('button'));These don't actually assert anything (other than implicitly, that getByText()/getByRole()) didn't throw before expect() was even called. This would be equivalent:
getByText('report');
getByRole('button');Let's add a lint against doing nothing with the return value of expect() in tests: it should always be chained with a matcher. In the examples above, that could be:
import '@testing-library/jest-dom/extend-expect';
expect(getByText('report')).toBeVisible();
expect(getByRole('button')).toBeVisible();or similar.