@@ -151,16 +151,24 @@ export function hasThenProperty(node: TSESTree.Node): boolean {
151151 ) ;
152152}
153153
154- export function hasChainedThen ( node : TSESTree . Node ) : boolean {
154+ export function hasPromiseHandlerProperty ( node : TSESTree . Node ) : boolean {
155+ return (
156+ isMemberExpression ( node ) &&
157+ ASTUtils . isIdentifier ( node . property ) &&
158+ [ 'then' , 'catch' ] . includes ( node . property . name )
159+ ) ;
160+ }
161+
162+ export function hasChainedPromiseHandler ( node : TSESTree . Node ) : boolean {
155163 const parent = node . parent ;
156164
157- // wait(...).then(...)
165+ // wait(...).then(...) or wait(...).catch(...)
158166 if ( isCallExpression ( parent ) && parent . parent ) {
159- return hasThenProperty ( parent . parent ) ;
167+ return hasPromiseHandlerProperty ( parent . parent ) ;
160168 }
161169
162- // promise.then(...)
163- return ! ! parent && hasThenProperty ( parent ) ;
170+ // promise.then(...) or promise.catch(...)
171+ return ! ! parent && hasPromiseHandlerProperty ( parent ) ;
164172}
165173
166174export function isPromiseIdentifier (
@@ -214,7 +222,7 @@ export function isPromisesArrayResolved(node: TSESTree.Node): boolean {
214222 * - it belongs to the `await` expression
215223 * - it belongs to the `Promise.all` method
216224 * - it belongs to the `Promise.allSettled` method
217- * - it's chained with the `then` method
225+ * - it's chained with the `then` or `catch` method
218226 * - it's returned from a function
219227 * - has `resolves` or `rejects` jest methods
220228 * - has `toResolve` or `toReject` jest-extended matchers
@@ -243,7 +251,7 @@ export function isPromiseHandled(nodeIdentifier: TSESTree.Identifier): boolean {
243251 )
244252 return true ;
245253 if ( hasClosestExpectHandlesPromise ( node . parent ) ) return true ;
246- if ( hasChainedThen ( node ) ) return true ;
254+ if ( hasChainedPromiseHandler ( node ) ) return true ;
247255 if ( isPromisesArrayResolved ( node ) ) return true ;
248256 } ) ;
249257}
0 commit comments