Promises are a great way of doing async programming. But testing with promises can be a bit cumbersome, even with the use of the arrow functions syntax. Recently I've found a small and nice package to help to stub tests using Sinon, and the library is sinon-stub-promise. function fetchMovieData() { return fetch("/movies") .then(res => { return res.json(); }) .then(movies => { return movies; }); }
![How to stub promises using Sinon.JS](https://cdn-ak-scissors.b.st-hatena.com/image/square/991f6d90f8fd9854e66a3465fdbbd65d48b24a8b/height=288;version=1;width=512/https%3A%2F%2Ftemplecoding.com%2Fsocial%2Fbanner.jpg)