eslint-plugin-jest-dom icon indicating copy to clipboard operation
eslint-plugin-jest-dom copied to clipboard

fix(getQueryNodeFrom): move `Identifier` type checks to `getInnerNodeFrom`

Open ricardozv28 opened this issue 3 years ago • 1 comments

What: Move logic for checking if expression type is Identifier to getInnerNodeFrom method

Why: As reported on issue #203, features like .toBeDisabled() are not getting recommend as fixes for code like the following:

const button = getByRole('button', { name: 'My Button' });
expect(button.disabled).toBe(true);

How: After a little bit of digging, I noticed that when using getByRole method the type of the expression that was getting passed to getInnerNodeFrom was a MemberExpression, which was being handled by in the switch statement, expression.object was getting passed now to getInnerNodeFrom which was the type of 'Identifier' but since that case is not getting handled in the method, the returned expression didn't have a property .callee which was making getQueryNodeFrom to return isDTLQuery as false

Checklist:

  • [ ] Documentation N/A
  • [ ] Tests N/A
  • [x] Ready to be merged

Fix #203

ricardozv28 avatar Jan 21 '22 23:01 ricardozv28

Codecov Report

Merging #255 (5ddce16) into main (48fce31) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #255   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines          581       581           
  Branches       167       165    -2     
=========================================
  Hits           581       581           
Impacted Files Coverage Δ
src/assignment-ast.js 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Jan 21 '22 23:01 codecov[bot]

Can you add a few test cases please?

trying to pick this up again in my free time, do you have some existing unit test examples that I can take a look at for reference??

ricardozv28 avatar Jan 13 '23 04:01 ricardozv28

@ricardozv28 tests for rules live here - you don't need to add tests to every rule, but we should have a couple if possible (including one here for toBeDisabled)

G-Rath avatar Jan 14 '23 17:01 G-Rath

:tada: This PR is included in version 5.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Jun 04 '23 20:06 github-actions[bot]