1.0.0 • Published 5 years ago

promise-spy v1.0.0

Weekly downloads
30
License
MIT
Repository
github
Last release
5 years ago

npm npm GitHub issues

Travis David

promise-spy

Sets up an interceptor for Promise's which so we can get them later statically

Installation ... someday

npm install --save-dev promise-spy

Usage

function doSomethingAsyncThatIsInaccessible(cb) {
    new Promise(resolve => {
        cb();
        resolve();
    });
}

describe('Some Test', () => {
    beforeEach(() => {
        PromiseSpy.install();
    });
    afterEach(() => {
        PromiseSpy.uninstall();
    });

    it('should do something', async () => {
        const callback = sinon.stub();
        doSomethingAsyncThatIsInaccessible(callback);

        await PromiseSpy.wait();

        expect(callback.calledOnce).to.equal(true);
    });
});