Closed tom-mayer closed 5 years ago
Hey
I have a test that looks like this:
it('should reject', async (done) => { when(mongoMock.start()).thenReject(); try{ await instance(mongoMock).start(); console.log('fulfilled'); }catch(err){ console.log('rejected'); } //.... });
This does not go into the catch block as I would expect. If I substitute the when line with
catch
when
when(mongoMock.start()).thenReturn(Promise.reject());
the code works as expected.
The start funciton of the mongo class looks something like this:
protected async startServices(): Promise<void> { try { // await some async stuff return Promise.resolve(); }catch(err){ return Promise.reject(); } }
Should be fixed in 2.3.2 version. thenReject method requires error to be passed to it. But now (in new version) it throws default error if none has been passed.
2.3.2
thenReject
Thanks for reporting this.
Hey
I have a test that looks like this:
This does not go into the
catch
block as I would expect. If I substitute thewhen
line withthe code works as expected.
The start funciton of the mongo class looks something like this: