Jasmine.clock().mockDate() not freezing the time clock

539 views
Skip to first unread message

Cody Stamps

unread,
Mar 7, 2016, 4:34:20 PM3/7/16
to Jasmine
Hey all,

Its my understanding that if we call jasmine.clock().mockDate(new Date(2016, 3, 7)); that I essentially freeze the time right?

The use case is I want to freeze the time, then call moment() in my actual code. Moment() should return a date matching 2016-4-7 00:00:00 GMT-0400 (EDT) right?

Thanks,

Cody

Gregg Van Hove

unread,
Mar 10, 2016, 12:44:29 PM3/10/16
to jasmi...@googlegroups.com
Using `mockDate` will stub out the `Date` constructor based on the value passed in, so as long as `Moment()` calls through to `new Date()` (with no arguments) at some point, you should get the mocked date. If Moment ends up constructing a specific `Date` (by specifying in the constructor), then you will get whatever date it constructs.

Hope this helps. Thanks for using Jasmine!

-Gregg

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at https://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages