promise-spy

1.0.0 • Public • Published

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);
    });
});

Package Sidebar

Install

npm i promise-spy

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

41.5 kB

Total Files

17

Last publish

Collaborators

  • ammmze