Description
- Version: 10.5.0
- Platform: MacOS 10.13.2
- Subsystem: None
While writing tests for a project I found myself wanting to assert that the return value from a function was an instance of Http2SecureServer
. However, upon trying to find the export for Http2SecureServer
, I wound up at https://github.com/nodejs/node/blob/master/lib/internal/http2/core.js and found that the class isn't actually listed in the exports. So there's no discernible way to run an instanceof
against my return variable, as I can't reference the class.
It's an unfortunate limitation; while testing that an object is an instance of tls.Server
is fine and good, I would much rather add an extra layer of assertiveness and make sure that my return value was in fact an instance of Http2SecureServer
, as the mechanisms in my use case can also return https.Server
, which also inherits from tls.Server
.
On the surface this seems like a glaring omission. But there's probably a reason for that. What's the scoop?
Update: It would seem the same is true for Http2Server
as well.