# testing-library-query-assertion

Rule `sonarjs/testing-library-query-assertion`. Testing Library queries should match presence assertions

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1375 by reach, #676 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/testing-library-query-assertion` | yes | safe | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-9027/) |

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/testing-library-query-assertion": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/testing-library-prefer-query-by-disappearance](https://lintradar.dev/rules/sonarjs/testing-library-prefer-query-by-disappearance.md): Testing Library disappearance waits should use non-throwing queries
- [sonarjs/todo-tag](https://lintradar.dev/rules/sonarjs/todo-tag.md): Track uses of "TODO" tags
- [sonarjs/test-check-exception](https://lintradar.dev/rules/sonarjs/test-check-exception.md): Tests should check which exception is thrown
- [sonarjs/unused-import](https://lintradar.dev/rules/sonarjs/unused-import.md): Unnecessary imports should be removed
- [sonarjs/table-header-reference](https://lintradar.dev/rules/sonarjs/table-header-reference.md): Table cells should reference their headers
- [sonarjs/unused-named-groups](https://lintradar.dev/rules/sonarjs/unused-named-groups.md): Names of regular expressions named groups should be used

---

Web page: https://lintradar.dev/rules/sonarjs/testing-library-query-assertion. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
