Angular NGRX test a selection subscription with pipe skip

Discussão em 'Angular' iniciado por John, Maio 2, 2025.

  1. John

    John Guest

    My method works the way I want it to, however, the test is failing when I add the pipe(skip(1))

    How do I test an observable with a pipeable skip. Here is my method:

    getSomething() {
    this.store.pipe(select(selectSomeStatus))
    .pipe(skip(1)) // TEST WILL PASS WHEN LINE REMOVED
    .subscribe((data) => {
    // TEST NOT GETTING HERE
    });
    }


    Here is the test:

    it('should getSomething', fakeAsync(() => {
    // Arrange
    const mockResult = [];
    store.overrideSelector(selectSomeStatus, mockResult);
    store.refreshState();


    // Act
    component.getSomething();
    tick();

    // Assert
    // Assertions will go here
    }));


    I'm not sure what I am doing wrong. Any help would be much appreciated.

    Continue reading...

Compartilhe esta Página