Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

angular jasmin mock http response

 public static mockGetProfile(){
    const response = JSON.parse(`
     "name": "abc",
     "active": true,
     ...all other json fields that you want
     `);

    let obs = new Observable((subscriber) => {
        setTimeout(()=>{
            subscriber.next(response);
            subscriber.complete();
        }, 3000);
    });
    return obs;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #angular #jasmin #mock #http #response
ADD COMMENT
Topic
Name
4+8 =