Skip to content

Commit 5ae2641

Browse files
committed
Fixing rejection tests
1 parent 85fad97 commit 5ae2641

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/jest-mock/src/__tests__/jest_mock.test.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,9 @@ describe('moduleMocker', () => {
422422

423423
expect(promise).toBeInstanceOf(Promise);
424424

425-
return promise.catch(rejection => expect(rejection).toBe(err));
425+
return promise
426+
.then(() => Promise.reject(new Error('did not reject')))
427+
.catch(rejection => expect(rejection).toBe(err));
426428
});
427429

428430
it('supports mocking rejectable async functions only once', () => {
@@ -432,10 +434,12 @@ describe('moduleMocker', () => {
432434
fn.mockRejectedValue(defaultErr);
433435
fn.mockRejectedValueOnce(err);
434436

435-
const promise1 = fn().catch(rejection => expect(rejection).toBe(err));
436-
const promise2 = fn().catch(rejection =>
437-
expect(rejection).toBe(defaultErr),
438-
);
437+
const promise1 = fn()
438+
.then(() => Promise.reject(new Error('did not reject')))
439+
.catch(rejection => expect(rejection).toBe(err));
440+
const promise2 = fn()
441+
.then(() => Promise.reject(new Error('did not reject')))
442+
.catch(rejection => expect(rejection).toBe(defaultErr));
439443

440444
return Promise.all([promise1, promise2]);
441445
});

0 commit comments

Comments
 (0)