Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
Angular 2 Testing Service with nested Service

base.service.ts

export class BaseService {
    constructor(private http:Http){}
        search(segment: string, param: string){
             //build url
             this.http.get(....){}
        }
    }

my.service.ts

export class MyService {
    constructor(private baseService:Baservice){}
        search(segment: string, param: string){
             //build url
             this.baseService.search('people','1'){}
        }
    }

Base Service is a generic service that will build url and get data from server and return observable.

Now I want to put MyService under test. How can I mock Base Service because the different data sets will be returned with different 'segment' and 'param'

Thanks

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!