Private method Unit testing with Jasmine

前端 未结 5 1769
情深已故
情深已故 2021-02-04 01:40

I was coding test cases for an angular application using jasmine. But many internal methods are declared as private in the services.

Example:

App.service         


        
5条回答
  •  暖寄归人
    2021-02-04 02:04

    Thanks jabko87.

    In addition, if you want to pass the the arguments use the below example:

    const myPrivateSpy = spyOn(service, 'transformNative').and.callThrough();
     myPrivateSpy.call(service, {name: 'PR'});
    

    Note: Here service is the Class, transformNative is the private method and {name: 'PR'} passing an object argument

提交回复
热议问题