Observable "source is deprecated" error on npm lint

Viewed 764

I get "source is deprecated: This is an internal implementation detail, do not use." when I run the command npm lint on my code below:

 set stream(source: Observable<any>) {
    this.source = source;
  }

If I take it out, it satisfies the lint, but it breaks my unit tests. Why is this?

1 Answers

If you are testing effects, you need to update the approach. I have changed using the provideMockActions, the action would be an let actions$: Observable;

fdescribe('PizzaEffects', () => { let actions$: Observable;; let service: Service; let effects: PizzaEffects; const data = givenPizzaData();

    beforeEach(() => {
        TestBed.configureTestingModule({
            imports: [ApolloTestingModule],
            providers: [
                Service, 
                PizzaEffects, 
                Apollo, 
                // { provide: Actions, useFactory: getActions }, remove
                provideMockActions(() => actions$),
            ]
        });

        actions$ = TestBed.get(Actions);
        service = TestBed.get(Service);
        effects = TestBed.get(PizzaEffects);

        spyOn(service, 'loadData').and.returnValue(of(data));
    });

    describe('loadPizza', () => {
        it('should return a collection from LoadPizzaSuccess', () => {
            const action = new TriggerAction();
            const completion = new LoadPizzaSuccess(data);
            actions$ = hot('-a', { a: action });
            const expected = cold('-b', { b: completion });

            expect(effects.getPizzaEffect$).toBeObservable(expected);
        });
    });
});
Related