Skip to content

feat: expand async matcher support #1040

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

puglyfe
Copy link

@puglyfe puglyfe commented Jul 10, 2025

Checks

Changes

This expands support for additional async matchers (specifically, jasmine) to reduce false positives for await-async-queries and await-async-utils. As mentioned in the linked issue, I understand any hesitancy to include framework-specific logic, but I think this is a relatively trivial addition to open up support to another testing framework.

Context

Fixes #1039

@Belco90 Belco90 self-requested a review July 10, 2025 21:03
@Belco90 Belco90 added the enhancement New feature or request label Jul 10, 2025
Copy link

codecov bot commented Jul 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.49%. Comparing base (b1a4da7) to head (5585d68).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1040      +/-   ##
==========================================
+ Coverage   96.30%   96.49%   +0.18%     
==========================================
  Files          47       49       +2     
  Lines        2542     2679     +137     
  Branches     1047     1110      +63     
==========================================
+ Hits         2448     2585     +137     
  Misses         94       94              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Thanks for your contribution! I added some comments, but the implementation seems fine in general.

if (
isCallExpression(node) &&
ASTUtils.isIdentifier(node.callee) &&
node.parent &&
isMemberExpression(node.parent) &&
node.callee.name === 'expect'
['expect', 'expectAsync'].includes(node.callee.name)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we should check that expect is combined with the right subset handlers (resolves, rejects, etc), and expectAsync is combined with its subset handlers (toBeRejectedWith, toBeResolved, etc).

I think it's fine as it is, so we don't need to check if the combination between expect and matcher exists, as the code won't work if doesn't.

Copy link
Author

Choose a reason for hiding this comment

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

i had the same thought and came to the same conclusion. there will be plenty of other signals elsewhere if an incompatible combination is used - TS, runtime errors, etc.

@@ -261,6 +261,24 @@ ruleTester.run(RULE_NAME, rule, {
`
),

// jasmine async matchers are valid
Copy link
Member

Choose a reason for hiding this comment

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

I'm trying to think any invalid case that should be added, but there is none probably, since the improvement only includes more valid combinations.

@puglyfe puglyfe requested a review from Belco90 July 11, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support additional async matchers when detecting handled promises
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy