Executing a cancelled action error in my angular unit tests

Discussão em 'Angular' iniciado por Arjun, Outubro 24, 2024.

  1. Arjun

    Arjun Guest

    I am working on angular 16 project and its jasmine karma tests are flaky in nature sometimes they pass but soemtimes they fail. The error logs is -

    Error: executing a cancelled action
    at AsyncAction.execute (node_modules/rxjs/dist/esm/internal/scheduler/AsyncAction.js:41:20)
    at AsyncScheduler.apply (node_modules/rxjs/dist/esm/internal/scheduler/AsyncScheduler.js:17:33)
    at apply (node_modules/zone.js/fesm2015/zone.js:2367:41)
    at _ZoneDelegate.invokeTask (node_modules/zone.js/fesm2015/zone.js:402:31)
    at ProxyZoneSpec.onInvokeTask (node_modules/zone.js/fesm2015/zone-testing.js:304:39)
    at _ZoneDelegate.invokeTask (node_modules/zone.js/fesm2015/zone.js:401:60)
    at Zone.runTask (node_modules/zone.js/fesm2015/zone.js:173:47)
    at apply (node_modules/zone.js/fesm2015/zone.js:472:48)
    at data.args.<computed> (node_modules/zone.js/fesm2015/zone.js:2347:32)



    version using - angular : 16.2.8 rxjs : 7.8.1 zone.js : 0.13.3

    I used takeUntil operator for my observables to unsubscribe when component gets destroyed and added afterEach in my tests for cleanup of observables -

    afterEach(() => {
    component['destroyed$'].next();
    component['destroyed$'].complete();
    });


    But after this also the flaky nature of tests did not resolve.

    Please guide me how to fix this. I am new to angular

    Continue reading...

Compartilhe esta Página