-1

I'm trying to create my very first test case using Jasmine and its my first attempt in writing test cases(actually just started learning). I'm currently referring This site to write test case

Here I'm facing two issues.

  1. The signature '(token: any, notFoundValue?: any): any' of 'TestBed.get' is deprecated.ts(6387) testing.d.ts(382, 9): The declaration was marked as deprecated here. (method) TestBedStatic.get(token: any, notFoundValue?: any): any (+1 overload)

  2. Argument of type '(typeof EmployeeService)[]' is not assignable to parameter of type 'Type | AbstractType | InjectionToken'. Type '(typeof EmployeeService)[]' is missing the following properties from type 'AbstractType': prototype, apply, call, bind, and 4 more.ts(2345)

employee model

export interface Employee {
    name: string;
    desc: null | string;
    action: string;
    obj: Obj;
    action: any;

}

export interface Obj {
    empId: string;
    empName: string;
    reportTo: string;
    country: string;
    region: string;
    empStatus: string;
    department: string;
}

testcase

describe('DataAccessService', () => {
    let httpTestingController: HttpTestingController;
    let dataAccessService: EmployeeService;
    // let baseUrl = 'czm/getCustomerList';
    let traveller: Employee;
  
    beforeEach(() => {
      TestBed.configureTestingModule({
        imports: [HttpClientTestingModule]
      });
  
      httpTestingController = TestBed.get(HttpTestingController);
      traveller = {
        name: 'Jane',
        desc: 'Jane',
        action: '',
        obj: {
          empId: 'Jane',
          empName: 'Jane',
          reportTo: 'TD1',
          country: 'USA',
          region: 'USA',
          empStatus: 'Inactive',
          department: 'HR - Marketing',
        }
      };
    });
  
    beforeEach(inject(
      [EmployeeService],
      (service: EmployeeService) => {
        dataAccessService = service;
      }
    ));
  });

Could someone tell me how to resolve this issue?

I'm requesting some jasmine experts to create stackblitz if possible

Thanks All

Mr. Learner
  • 978
  • 2
  • 18
  • 48

1 Answers1

1

TestBed.get is deprecated, see this answer. Just use TestBed.inject instead of TestBed.get since Angular 9.

serrulien
  • 695
  • 4
  • 14