How to mock jwtDecode

Discussão em 'Angular' iniciado por Mike, Novembro 11, 2024.

  1. Mike

    Mike Guest

    Hello I am trying to write a test to decode a token using jwtDecode, and my code is as follows.

    it('should test labId with more than 4 chars', inject([OauthService], (oauthService: OauthService) => {

    const parsedToken = { principal: '1234lab' };

    spyOn(jwtDecode, 'default').and.returnValue(parsedToken);


    component.setUpOAuth();
 oauthService.onLoggedIn.next();

    expect(LabIdManager.labId).toBe('1234lab');

    }));


    However I keep getting the following error.

    Argument of type '"default"' is not assignable to parameter of type 'never'.

    Any help would greatly appreciated.

    Continue reading...

Compartilhe esta Página