This site has been updated.
Reload to display the latest version?
(click here)

Tag:  moment.js

How to test code that uses moment.js

05 November, 2018
I’m going to talk about unit tests here, not any other kind of tests. And unit tests have, in my opinion, the following list of criteria that they have to meet. This list makes it hard to write tests for code that use external libraries, especially ones that manipulate time: Unit tests should be able to run on the developer’s machine as well as on the remote server Unit tests shouldn’t relate to timezone Each tested class (or component) should be tested independently from external libraries…

Replacing moment.js with date-fns

04 November, 2018
It’s known that moment.js is a widely used library for date and time manipulations. Obviously it is the case because of the limitations of standard JavaScript API, but today we’re not going to judge standard language features. Let’s accept the insufficiency of built-in tools and investigate whether or not I can replace moment.js with a smaller library. Addy Osmani suggested in the recent video called “The State of JavaScript”, using date-fns.js as a replacement for moment.js. It’s not the first…