Angular unit test with private variable

Discussão em 'Angular' iniciado por Ish, Julho 24, 2025.

  1. Ish

    Ish Guest

    I want to write the unit test for the private variable. But Jasmine is not allowing me to use it. Can someone explain me how to do it?

    export class TestComponent implements OnInit {
    private resolve;

    public testPrivate() {
    this.resolve(false);
    }
    }

    it(
    'should test private variable', () => {
    component.testPrivate();
    expect(component.resolve).toEqual(false);
    });

    Continue reading...

Compartilhe esta Página