How To Easily Mock Moment.js In Jest - I Like Kill Nerds

added by JavaScript Kicks
12/4/2019 10:33:45 AM

325 Views

Recently whilst writing some unit tests in Jest, I had to test some code that took ISO date strings and converted them to formatted date strings, then code that converts them back to ISO strings before it's sent to the server. My first attempt was to use jest.mock and mock each individual method.


0 comments