substantial / sinon-stub-promise

Synchronous Promise stubbing for Sinon.JS
MIT License
85 stars 11 forks source link

Chained THEN not working as expected #29

Open w3apps opened 7 years ago

w3apps commented 7 years ago

There is a problem when I try to stub chained promises like

return async1()
    .then((res) => {
      console.log('async1 finished', res);
      return async2();
    })
    .then((res2) => {
      console.log('async2 finished', res2);
    })

The problem is that the moment I trigger .resolves() on the first stub it automatically triggers the second then. The problem seems to be on:

I created a PR https://github.com/substantial/sinon-stub-promise/pull/28 so you can check exactly what happens (this should not be merged). I tried to fix this but it didn't really work out as I was hoping. Any ideas?