1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Problem with getting tick from ngrx effect in marble testing JEST

Discussão em 'Angular' iniciado por patryk_le, Outubro 16, 2024.

  1. patryk_le

    patryk_le Guest

    I have NgRx store effect like this:

    checkStatus$ = createEffect(() => {
    return this.actions$.pipe(
    ofType(Actions.checkstatus),
    fetch({
    run: ({ method }) => {
    const timeout: Observable<number> = interval(1000 * 60 * 2);
    //rest of code
    timeout.pipe(take(1),).subscribe(() => {
    return Actions.timeout();
    });
    }
    })
    );
    });


    And i try to write jest test to check if timeout action is returned

    I tried to test it in jest like this:

    it('should return timeout action', () => {
    testScheduler.run(helpers => {
    const { hot, cold, expectObservable } = helpers;

    actions$.next(Actions.checkstatus({method: method});

    expectObservable(effects.checktStatus$).toBe('120s (b|)', { b: Actions.timeout() })
    });
    });


    but all i get is

    - Expected - 20
    + Received + 1

    - Array [
    - Object {
    - "frame": 120000,
    - "notification": Object {
    - "error": undefined,
    - "kind": "N",
    - "value": Object {
    - "type": "[action] timeOut",
    - },
    - },
    - },
    - Object {
    - "frame": 120000,
    - "notification": Object {
    - "error": undefined,
    - "kind": "C",
    - "value": undefined,
    - },
    - },
    - ]
    + Array []


    Am i doing something wrong? What is the problem here?

    Continue reading...

Compartilhe esta Página