angular jasmine mock http request

Solutions on MaxInterview for angular jasmine mock http request by the best coders in the world

showing results for - "angular jasmine mock http request"
Andrea
21 Jul 2018
1// Angular - Jasmine
2// Fake a HTTP request
3
4public getSomething() : Observable<any>{
5    let response: DataResult<any> = { data: "something" };
6    return of(response);
7}
Marie
08 Jan 2020
1 public static mockGetProfile(){
2    const response = JSON.parse(`
3     "name": "abc",
4     "active": true,
5     ...all other json fields that you want
6     `);
7
8    let obs = new Observable((subscriber) => {
9        setTimeout(()=>{
10            subscriber.next(response);
11            subscriber.complete();
12        }, 3000);
13    });
14    return obs;
15}