Sunday, 16 April 2017

How to use nockback with promises?

I am trying to use nockBack to automate my fixtures recording/playback with code that uses promises and chai-as-promised.

But I can't figure out how to make the async nockBack work with it.

context('sad path', () => {
  it('should reject the promise', () => {
    return nockBack('myfixture.json')
      .then(() => assert.isRejected(myPromise.doIt(), Error));
  });
});

This fails with a timeout because no callback is ever called.

I also tried with const nockBack = Promise.promisifyAll(require('nock').back), but it still times out.

Any thoughts on how to use nockBack with promises and chai-as-promised?



via springloaded

No comments:

Post a Comment