Open jrencz opened 11 months ago
After a brief look into the rule code I can narrow the cause of what I see as a problem down to this section:
There's a design decision to enforce all expect
calls to be awaited, but it's not even covered fully (e.g. it won't trigger the rule if it's expect(…).not.toBe(…)
where the pattern of CallExpression>MemberExpression>CallExpression, which this chunk above detects is not preserved)
I went through the history of changes, of the rule, and I see that expect
initially was one of FUNCTIONS_TO_BE_AWAITED
but then some refinements came, but I'm not sure why was it considered as "it needs to be awaited" at all - it's not at all obvious it should
Describe the bug Rule reports problem on following code:
if it's written this way:
rule doesn't complain.
Fix is proposed to prepend
expect((await promise).foo).toBe('bar')
which is incorrect as it doesn't need that in the first place.That's true Jest expect can be awaited, but then
should become
and fixer just prepends the
await
keywordAdditional context
@storybook/testing-library@0.2.0
@testing-library/user-event@14.4.3
eslint-plugin-storybook@0.6.12