-
-
Notifications
You must be signed in to change notification settings - Fork 733
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
update socket class with missing address method #1643
Comments
This sounds like a good feature to add to our mock Socket class. There was a recent PR adding the By the way, what would you have the mock function return? |
Howdy @paulmelnikow , Thanks for following up with me. I meant to include a the actual reference to to the My guess, and I'm not 100% here, is that they are from The idea was through Thoughts on that -- or did I get way into the trenches here? |
The Off the top of my head, something like this? constructor(options) {
// ... existing stuff
this.remotePort = parseInt(options.port) || this.authorized ? 443 : 80
this.remoteFamily = options.family === 6 ? 'IPv6' : 'IPv4'
this.remoteAddress = options.family === 6 ? '::1' : '127.0.0.1'
}
address() {
return {
port: this.remotePort,
family: this.remoteFamily,
address: this.remoteAddress
}
} |
Your idea looks amazing to me! 😃 |
@kvernon do you want to pick this up and add tests? |
It's been a little confusing working with |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions. |
🎉 This issue has been resolved in version 11.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Context
currently, I found nock and am trying to test out a http module flow. along the way, we require extracting the
address()
result object.w/in the response, we have this event:
What are you trying to do and how would you want to do it differently? Is it something you currently you cannot do? Is this related to an issue/problem?
In the case of our tests, because the method doesn't exist, the test throws an exception/error, which causes the test to fail.
Alternatives
I'd love to know of alternatives: like could I assign a mock/stub socket to contain that address method?
Can you achieve the same result doing it in an alternative way? Is the alternative considerable?
Currently I know no way to make this happen
Has the feature been requested before?
I do no think so
If the feature request is accepted, would you be willing to submit a PR?
Yes, I can give it a whirl :)
The text was updated successfully, but these errors were encountered: