0

EDIT

I boiled down the problem. The following code yields an error in tests, but works as expected in the browser (see https://github.com/prumand/jest-marbles-merge-map and https://github.com/ReactiveX/rxjs/issues/4837)

  • tests: returns a WE_FINISH
  • browser (expected): MY_NEW_ERROR
 // code
export default function basicMergeMapObs(
    action$: Observable<Action>
) : Observable<any> {
    return action$.pipe(
        filter((val: Action) => {
            throw new Error('We stop here')
        }),
        map((val: Action) => ({
            type: 'WE_FINISH',
        })),
        catchError(() => of({
            type: 'MY_NEW_ERROR',
        }))
    )
}

// test
it('should yield an MY_ERROR', () => {
    const source = of({
        type: 'TEST',
        status: 'NEW'
    })

    getScheduler().run(helpers => {
        const { expectObservable, cold } = helpers
        expectObservable(
            basicMergeMapObs(
                source
            )
        ).toBe(
            '(t|)',
            {
                t: { type: 'MY_NEW_ERROR' }
            }
        )
    })
})

function getScheduler() {
    return new TestScheduler((actual, expected) => {
        expect(actual).toMatchObject(expected);
    });
}

UPDATE 19.06.2019

I added cartants example from the given github issue, which works fine. Still my example fails. No idea why. IMO it should always throw an error.

And yet another update, the tests don't fail on linux, but only on my windows machine

UPDATE 02.07.2019 :O seemed to be a issue with endpoint-security solution we use ...

prumand
  • 160
  • 10

0 Answers0