plaa / TimeShift-js

Library for mocking JavaScript's Date object
MIT License
65 stars 28 forks source link

applying native methods on TimeShift.Date instances throws exception #3

Closed salomvary closed 10 years ago

salomvary commented 10 years ago

If a native date function is applied with a mock one, Chrome will throw "this is not a Date object" exception (I'm sure other browsers won't tolerate this either).

This can be problematic when for example a third party library holds a reference to the native date prototype and call them with passed in TimeShift Dates.

I'm not aware that there is any way of fixing this but it should be mentioned in the Ceveats section imho.

plaa commented 10 years ago

Shouldn't it be possible to work around this by initializing TimeShift-js before loading the library? (Of course this may be problematic in some cases.)

salomvary commented 10 years ago

It is indeed, but that might not always be an option (and I guess in most cases the exception above comes as a surprise and hard to decipher).

plaa commented 10 years ago

Added note in the caveats.