undici
undici copied to clipboard
fix: MockResponseCallbackOptions type
This relates to...
https://github.com/nodejs/undici/issues/1583
Rationale
The issue is self-explanatory. It's kinda complicated to get what the actual types are. So I decided to print the opts
argument:
https://github.com/nodejs/undici/blob/0b5a4515f3b7c0bbdc873ea172c47a56e515b167/lib/mock/mock-interceptor.js#L124
This is what I got:
From what I understand, only path
and method
are sure to exist.
Changes
Features
Bug Fixes
Breaking Changes and Deprecations
Status
- [ ] I have read and agreed to the Developer's Certificate of Origin
- [ ] Tested
- [ ] Benchmarked (optional)
- [ ] Documented
- [ ] Review ready
- [ ] In review
- [ ] Merge ready
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 94.17%. Comparing base (
0b5a451
) to head (9249b4b
). Report is 163 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #2951 +/- ##
==========================================
+ Coverage 93.68% 94.17% +0.49%
==========================================
Files 87 90 +3
Lines 23973 24432 +459
==========================================
+ Hits 22458 23009 +551
+ Misses 1515 1423 -92
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@mcollina @metcoder95 I think this existing test already covers the callback options types:
expectAssignable<MockScope>(mockInterceptor.reply((options) => {
expectAssignable<MockInterceptor.MockResponseCallbackOptions>(options);
return { statusCode: 200, data: { foo: 'bar'}
}}))
Even so, I saw that that there was a different test for options.header, so I tested the rest of possible values in this same test.