const mockFailureResponse = "Something bad happened!" ; jest . mock ( './async-login-function' , ( ) => { return { asyncLoginFunction : ( ) => { return Promise . reject ( mockFailureResponse ) ; } } ; } ) ; import loginService from './simple-login.service' ; describe ( "loginService" , ( ) => { it ( 'should return a promise containing the id data.' , async ( ) => { const fakeParams = { } ; const result = await loginService ( fakeParams ) ; expect ( result ) . toEqual ( mockFailureResponse ) ; } ) ; } ) ;