Adding delay in HttpTestingController - Angular Unit test

Discussão em 'Angular' iniciado por Arnab Mukherjee, Abril 29, 2025.

  1. Trying to validate timeout from db queries, not able to achieve it via HttpTestingController.

    Not sure how to design the UT. Where to add the replicate the timeout from flush

    it('test timeout', () => {

    service.getData('2025-10-12', '2025-10-16').subscribe(
    {
    next: data => {
    expect(data).not.toBeNull();
    },
    error: error => {
    expect(error).toBeNull(); // handling all missing keys
    }
    }
    );

    // mocking endpoint - binding
    const response = httpController.expectOne({
    method: 'GET',
    url: RestServerSA.RELEASES_OVERVIEW_RANGE
    });

    // mocking response from endpoint
    response.flush({});
    });

    Continue reading...

Compartilhe esta Página