I\'m testing my GraphQL api using Jest.
I\'m using a separate test suit for each query/mutation
I have 2 tests (each one in a separate test suit) where I mock on
For Angular + Jest:
import { throwError } from 'rxjs'; yourMockInstance.mockImplementation(() => { return throwError(new Error('my error message')); });
Change .mockReturnValue with .mockImplementation:
.mockReturnValue
.mockImplementation
yourMockInstance.mockImplementation(() => { throw new Error(); });