This is a follow up into my testing of our latest release candidate against the jsdom test suite. The callback issues have been sorted out but I also encountered a validation issue around the URL object that is used by jsdom. When we are passed a URL object, we test it using url instanceof URL but the URL object from jsdom is not the same as the global URL object.
Relying on instanceof is always tricky in JavaScript. We should instead favor checking for the structure of the object we expect which must have the following structure:
This is a follow up into my testing of our latest release candidate against the
jsdom
test suite. The callback issues have been sorted out but I also encountered a validation issue around theURL
object that is used byjsdom
. When we are passed aURL
object, we test it usingurl instanceof URL
but theURL
object fromjsdom
is not the same as the globalURL
object.Relying on
instanceof
is always tricky in JavaScript. We should instead favor checking for the structure of the object we expect which must have the following structure:This PR replaces the
instanceof
check with a validation for the above structure. This will pass for unknownurl
values that are instances ofURL
since they will have that structure and is already represented by the following test: https://github.com/salesforce/tough-cookie/blob/master/lib/__tests__/cookieJar.spec.ts#L1252-L1265