-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Labels
awaiting responseWaiting for a reply from the OPWaiting for a reply from the OPbugSomething isn't workingSomething isn't working
Description
Have you read the Troubleshooting section?
Yes
Plugin version
v6.2.0
ESLint version
v8.57.0
Node.js version
v20.5.0
package manager and version
pnpm 8.15.4
Operating system
macOs Sonoma
Bug description
At the moment when I import functions from react-test-renderer
and run my linter (eslint . --fix
) the testing-library/await-async-queries
triggers with a false-positive.
For example trying to use findAllBytype
triggers the rule " promise returned from findAllByType
query must be handled". But this version has no Promise returned making it redundant, e.g. :
it('has no blockquotes when loggedOut', () => {
const container = rendererCreateWithRedux(
<Intro {...loggedOutProps} />
).root;
expect(container.findAllByType('blockquote').length === 0).toBeTruthy();
expect(container.findAllByType('h1').length === 1).toBeTruthy();
});
The current work around is to disable this rule with an inline comment, but I would like this being resolved in a different way.
Steps to reproduce
- create a test file of your liking
- import
react-test-renderer
- use
findAllByType
in a test - run your linter
- observe result
Error output/screenshots
34:22 error promise returned from findAllByType
query must be handled testing-library/await-async-queries
ESLint configuration
Details
{
"env": {
"es6": true,
"browser": true,
"mocha": true,
"node": true,
"jest": true
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"babelOptions": {
"presets": ["@babel/preset-react"]
}
},
"root": true,
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:import/recommended",
"plugin:jsx-a11y/recommended",
"prettier"
],
"plugins": ["no-only-tests", "filenames-simple"],
"globals": {
"Promise": true,
"window": true,
"$": true,
"ga": true,
"jQuery": true,
"router": true
},
"settings": {
"react": {
"version": "16.4.2"
},
"import/resolver": {
"typescript": true,
"node": true
}
},
"rules": {
"import/no-unresolved": [2, { "commonjs": true }],
"import/named": "error",
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"import/order": "error",
"import/no-cycle": [2, { "maxDepth": 2 }],
"react/prop-types": "off",
"no-only-tests/no-only-tests": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
],
"filenames-simple/naming-convention": ["warn"]
},
"overrides": [
{
"files": ["**/*.ts?(x)"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": [
"./client/tsconfig.json",
"./tsconfig.json",
"./api/tsconfig.json",
"./shared/tsconfig.json",
"./tools/ui-components/tsconfig.json",
"./tools/client-plugins/browser-scripts/tsconfig.json",
"./web/tsconfig.json",
"./curriculum-server/tsconfig.json",
"./cypress/tsconfig.json",
"./e2e/tsconfig.json"
]
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/typescript"
],
"plugins": ["@typescript-eslint"],
"rules": {
"import/no-unresolved": "off",
"import/named": 0,
"@typescript-eslint/naming-convention": "off",
"testing-library/await-async-query": "off"
}
},
{
"files": [
"./tools/ui-components/**/*.test.[jt]s?(x)",
"./client/**/*.test.[jt]s?(x)"
],
"extends": [
"plugin:testing-library/react",
"plugin:jest-dom/recommended"
],
"rules": { "import/named": 2 }
},
{
"files": ["cypress/**/*.js"],
"globals": {
"cy": true,
"Cypress": true
}
},
{
"files": ["e2e/*.ts"],
"rules": {
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-assignment": "off"
}
},
{
"files": ["web/**/*.tsx"],
"extends": ["plugin:react/jsx-runtime"]
},
{
"files": ["**/api-server/**/*", "**/404.*"],
"rules": {
"filenames-simple/naming-convention": "off"
}
},
{
"files": ["**/api/src/**/*.ts"],
"plugins": ["jsdoc"],
"extends": ["plugin:jsdoc/recommended-typescript-error"],
"rules": {
"jsdoc/require-jsdoc": [
"error",
{
"require": {
"ArrowFunctionExpression": true,
"ClassDeclaration": true,
"ClassExpression": true,
"FunctionDeclaration": true,
"FunctionExpression": true,
"MethodDefinition": true
},
"publicOnly": true
}
],
"jsdoc/require-description-complete-sentence": "warn",
"jsdoc/tag-lines": "off"
}
}
]
}
Rule(s) affected
testing-library/await-async-queries
Anything else?
No response
Do you want to submit a pull request to fix this bug?
Yes, but need help
Metadata
Metadata
Assignees
Labels
awaiting responseWaiting for a reply from the OPWaiting for a reply from the OPbugSomething isn't workingSomething isn't working
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Belco90 commentedon Jun 11, 2025
Hi @Sembauke! I overlooked this issue, sorry about that.
This problem seems related to the Aggressive Reporting. Have you checked the Troubleshooting section to find more about restricting this behavior?
The query mechanism from the Aggressive Reporting is assuming all
find(All)By*
queries should be treated as Testing Library queries. You can disable this behavior with thecustom-queries
settings so the plugin stops reporting those queries not coming directly from Testing Library likefindAllByType
.Sembauke commentedon Jun 12, 2025
Thank you for the response Mario, it is greatly appreciated. It has been a while since I tried to solve this issue on my end and my brain decided to get rid of all the context.
But what I read from the "Aggressive Reporting Section":
Couldn't this be a cause for a lot of oversight? We might not be directly familiar with the utils we use. Nor the aggressive reporting being a thing itself.
It would be nice if you could bring me up to speed!