testdouble.js icon indicating copy to clipboard operation
testdouble.js copied to clipboard

"RangeError: Invalid time value" with Invalid Date

Open alexbepple opened this issue 4 years ago • 5 comments

Issue

td.verify throws weird error msg when call param has an Invalid Date inside it.

Environment

Node.js v12.13.1 [email protected]

Example Repo

Runkit Notebook

https://runkit.com/alexbepple/5eb3db7fda92cd001a8c3b9f

Code-fenced Examples

var td = require('testdouble')

> mock = td.func()
> td.verify(mock(new Date(undefined)))

throws

Thrown:
RangeError: Invalid time value
    at Date.toISOString (<anonymous>)

Further analysis

I have traced this issue to searls/stringify-object. It hasn't been updated for three years. https://www.npmjs.com/package/stringify-object-es5. It also does not accept issues!?!

It was forked from yeoman/stringify-object (https://www.npmjs.com/package/stringify-object). It was updated more recently (two years ago) and accepts issues.

What do you suggest that we do? I am happy to try fixing it myself. But it is unclear how to proceed.

alexbepple avatar May 07 '20 10:05 alexbepple

I turned issues on the repo if you want to take a look at it. I forked the repo because while I'd added a feature td.js needed (and which got merged), the main library broke back-compat with some JS version that we support (or supported) https://github.com/searls/stringify-object

searls avatar May 07 '20 10:05 searls

@searls I didn't realize there was such a close connection between td and stringify-object-es5. :-)

alexbepple avatar May 07 '20 11:05 alexbepple

@searls stringify-object-es5 seems to be way ahead of the published version. cp. searls/stringify-object/issues/1 Is td.js compatible with the current source? In other words, if we were to fix the RangeError with Invalid Date in stringify-object-es5, could td.js bump the version easily?

alexbepple avatar May 07 '20 11:05 alexbepple

So it seems. I believe the npm release is pegged at this branch: https://github.com/searls/stringify-object/commits/transform-es5

To be honest, whatever had caused us to fork in the first place may well be moot by this time with how far along JS language changes have come in the past 3 years, so it might be worth investigating if the build can pass with the upstream package first

searls avatar May 07 '20 11:05 searls

@searls So it seems. :)

alexbepple avatar May 07 '20 11:05 alexbepple

Stale. Closing. Please reopen if still relevant and I will look into it.

giltayar avatar Sep 16 '23 11:09 giltayar