Access a private variable in spec.ts, Angular6

Discussão em 'Angular' iniciado por raju, Setembro 26, 2024.

  1. raju

    raju Guest

    I am using a private variable in Angular-6 service.ts.

    private tagSubject = new Subject<any>();


    It is been used like

    sendNewTagMessage(message: string) {
    this.tagSubject.next({ text: message });
    }

    clearNewTagMessage() {
    this.tagSubject.next();
    }


    I want to write a unit test for tagSubject.

    I cant do service.tagSubject.subscribe in the spec.ts as it is giving error like Property 'tagSubject' is private and only accessible within class. What can I do now. Please help.

    Continue reading...

Compartilhe esta Página