eslint-plugin-testing-library
Advanced tools
Comparing version
@@ -37,3 +37,3 @@ "use strict"; | ||
exports.getAssertNodeInfo = getAssertNodeInfo; | ||
exports.hasClosestExpectResolvesRejects = hasClosestExpectResolvesRejects; | ||
exports.hasClosestExpectHandlesPromise = hasClosestExpectHandlesPromise; | ||
exports.getInnermostReturningFunction = getInnermostReturningFunction; | ||
@@ -174,3 +174,3 @@ exports.hasImportMatch = hasImportMatch; | ||
return true; | ||
if (hasClosestExpectResolvesRejects(node.parent)) | ||
if (hasClosestExpectHandlesPromise(node.parent)) | ||
return true; | ||
@@ -327,4 +327,10 @@ if (hasChainedThen(node)) | ||
'toReject', | ||
'toBeRejected', | ||
'toBeRejectedWith', | ||
'toBeRejectedWithError', | ||
'toBePending', | ||
'toBeResolved', | ||
'toBeResolvedTo', | ||
]; | ||
function hasClosestExpectResolvesRejects(node) { | ||
function hasClosestExpectHandlesPromise(node) { | ||
if ((0, is_node_of_type_1.isCallExpression)(node) && | ||
@@ -334,3 +340,3 @@ utils_1.ASTUtils.isIdentifier(node.callee) && | ||
(0, is_node_of_type_1.isMemberExpression)(node.parent) && | ||
node.callee.name === 'expect') { | ||
['expect', 'expectAsync'].includes(node.callee.name)) { | ||
const expectMatcher = node.parent.property; | ||
@@ -343,3 +349,3 @@ return (utils_1.ASTUtils.isIdentifier(expectMatcher) && | ||
} | ||
return hasClosestExpectResolvesRejects(node.parent); | ||
return hasClosestExpectHandlesPromise(node.parent); | ||
} | ||
@@ -346,0 +352,0 @@ function getInnermostReturningFunction(context, node) { |
{ | ||
"name": "eslint-plugin-testing-library", | ||
"version": "7.5.4", | ||
"version": "7.6.0", | ||
"description": "ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
283522
0.05%4852
0.12%