Skip to content
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

fix: adding types to jest matchers #880

Merged
merged 3 commits into from
Nov 29, 2024

Conversation

hanseltime
Copy link
Contributor

@hanseltime hanseltime commented Nov 26, 2024

Summary

This adds types to describe the FetchMockAdapters and updates the jest Expect object so that typescript and intellisense can provide correct typings. It also adds some typings to the extension.js code so that, if something changes, we'll see that the types fail to compile and we can make updates as needed.

Update - Additional Commit

This commit keeps support for the "patched fetch" and also adds support for FetchMock like the documentation details. It adds tests for both inputs and adds an error message if the input is neither FetchMock or a patched fetch instance.

@wheresrhys
Copy link
Owner

This is really great - thanks so much for the contribution 🙌

It will also need an update to the docs to explain that fetch can also be used. Are you happy to do that?

@wheresrhys wheresrhys merged commit 9071395 into wheresrhys:main Nov 29, 2024
10 checks passed
Copy link
Contributor

@Yihao-G Yihao-G left a comment

Choose a reason for hiding this comment

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

As documented here:

filter and options are the same as those used by fetchMock.callHistory.calls().

And calls()'s two arguments are optional:

calls(filter?: CallHistoryFilter, options?: RouteConfig): CallLog[] {

Comment on lines +18 to +19
filter: CallHistoryFilter,
options: UserRouteConfig,
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure filter and options should be optional here?

Comment on lines +28 to +29
filter: CallHistoryFilter,
options: UserRouteConfig,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Comment on lines +38 to +39
filter: CallHistoryFilter,
options: UserRouteConfig,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@hanseltime
Copy link
Contributor Author

As documented here:

filter and options are the same as those used by fetchMock.callHistory.calls().

And calls()'s two arguments are optional:

calls(filter?: CallHistoryFilter, options?: RouteConfig): CallLog[] {

@Yihao-G - if you think there is an issue with an already merged PR, I would encourage you to open an issue or submit your own PR. People normally don't look at their old merged PRs

@Yihao-G
Copy link
Contributor

Yihao-G commented Dec 24, 2024

I just wanted to double confirm though 😄 - I'm happy to make a PR if you guys think those two parameters should be optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants