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: default mock interceptor to GET #1285
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
/** Method to intercept on. */ | ||
method: string | RegExp | ((method: string) => boolean); | ||
/** Method to intercept on. Defaults to GET. */ | ||
method?: string | RegExp | ((method: string) => boolean); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test for the type? We use tsd!
could you also update the docs? |
Updated docs and added a type test! Sorry for the delay. |
Codecov Report
@@ Coverage Diff @@
## main #1285 +/- ##
==========================================
+ Coverage 94.11% 94.16% +0.04%
==========================================
Files 44 45 +1
Lines 4098 4112 +14
==========================================
+ Hits 3857 3872 +15
+ Misses 241 240 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
I am in the process of migrating an open source project from
node-fetch
toundici
. I am making heavy use ofnock
, which doesn't exactly work here :) One of the things I noticed is that nock tends to default to assumingGET
on interceptors, and I think it's a fairly accepted norm in terms of request libraries. This change makesmethod
optional on theMockClient.intercept
method, and defaults it to aGET
in that case.Not sure if this is a desirable API change or not, but thought it would aid in making the transition from
nock
to here a tad easier.