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

add ByA11yState to ALL_QUERIES_METHODS const #956

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

virenpepper
Copy link

Checks

Changes

  • add accessibility queries to ALL_QUERIES_METHODS so we can successfully target those queries while pattern matching

Context

  • prefer-screen-queries was failing for destructured a11y queries
  • this fixes that

- `prefer-screen-queries` was failing for destructured a11y queries

Signed-off-by: Viren Mohindra <[email protected]>
@Belco90
Copy link
Member

Belco90 commented Nov 1, 2024

Hi @virenpepper! Could you give us more context on this query? Where is it coming from?

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.33%. Comparing base (93a6ab9) to head (b2cfc74).
Report is 23 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #956      +/-   ##
==========================================
+ Coverage   96.23%   96.33%   +0.09%     
==========================================
  Files          44       46       +2     
  Lines        2419     2481      +62     
  Branches     1000     1028      +28     
==========================================
+ Hits         2328     2390      +62     
  Misses         91       91              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@virenpepper
Copy link
Author

virenpepper commented Nov 1, 2024

Hi @virenpepper! Could you give us more context on this query? Where is it coming from?

findByA11yState and queryAllByA11yState are part of the React Native Testing library [1] so when we ran this codemod [2] it didn't catch tests that looked like this ~

describe('test', () => {
      it('prefer-screen-queries does not throw an error here', async () => {
        const { findByA11yState } = render(<TestComponent/>);
       expect(queryAllByA11yState({ disabled: true }).length).toBe(1);
        const test = await findByA11yState({
          selected: true,
        });
      });
    });

but a couple things to callout,

  • it seems like this library does not support react-native-testing-library out of the gate, and
  • *ByA11yState is deprecated

so the tl;dr is maybe this PR can be closed? we are also facing issues where the prefer-screen-queries rule also fails to catch destructured rerender ie

    const { rerender } = render(<TestComponent />);

unsure how to proceed here, as of now we hacked the local library to catch these gaps

[1] https://callstack.github.io/react-native-testing-library/docs/api/queries#by-accessibility-state
[2] https://github.com/atsikov/eslint-jest-testing-library-codemod

eslint-plugin-testing-library - v6.4.0
ESLint - v9.13.0
Node.js - v20.10.0
package manager - yarn v1.22.19
Operating System - macOS Sequoia version 15.0

@MichaelDeBoey
Copy link
Member

@virenpepper As you correctly stated: this plugin (currently) doesn't support @testing-library/react-native.

I'll let @Belco90 decide what to do with this, but imo we should not add this and add full support in 1 go instead

Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

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

Hey @virenpepper! Sorry it took me so long to react to this.

I've seen there are several PRs for adding support for React Native in this plugin (this PR, #958, others in the past). Instead of having separated PRs for adding support here and there, we should unify the changes to support RN entirely in one go, similar to what was done in #973.

So we need to create an umbrella issue to gather what's missing in this plugin to fully support RN, then move the current work there, including the RN preset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants