Isn't this good enough?
expect(new URL('http://host/')).to.be.an.instanceOf(URL)
What is URL: whatwg-url, url.URL, or window.URL?
Hey @stevenvachon, thanks for the issue.
However, I can't reproduce it with latest chai and Node. Are you using a shim?
@stevenvachon URL is whatever you defined in your environment. new URL refers to the same thing. If you can do new URL, then you can certainly check if something is its instance. instanceOf() uses instanceof operator.
@shvaikalesh There's nothing to reproduce as this is a feature request. I use universal-url.
@deltaidea but being a standard object, I was hoping to get it built into chai. By your logic, having a('date') is pointless when we have instanceOf(Date).
Snippet above works with latest chai and Node. If it doesn't, probably shim doesn't set @@toStringTag.
@shvaikalesh which snippet?
It looks as though whatwg-url (which is ultimately what universal-url uses) does not support URL.prototype[Symbol.toStringTag], which value _should be_ "URL". I would say this is the issue of whatwg-url missing that value, and not a problem with chai's code, which would support that value existing.
I think given the above description I am going to close this. This is an issue with whatwg-url. I dont think we can be reasonably expected to support this behaviour.
Most helpful comment
It looks as though whatwg-url (which is ultimately what universal-url uses) does not support
URL.prototype[Symbol.toStringTag], which value _should be_"URL". I would say this is the issue of whatwg-url missing that value, and not a problem with chai's code, which would support that value existing.