Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Effects): Introduce new Effects testing module #70

Merged
merged 5 commits into from
Jul 12, 2017

Conversation

MikeRyanDev
Copy link
Member

Introduces a new testing module for @ngrx/effects that is designed to work well with marble testing.

Example usage:

import { provideMockActions } from '@ngrx/effects/testing';
import { hot } from 'jasmine-marbles';
import { MyEffects } from './my-effects';

describe('My Effects', () => {
  let effects: MyEffects;
  let actions: Observable<any>;

  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [
        MyEffects,
        provideMockActions(() => actions),
        // other providers
      ],
    });

    effects = TestBed.get(MyEffects);
  });

  it('should work', () => {
    actions = hot('--a--b--c--', { a: SomeAction, ... });

    expect(effects.someSource$).toBeObservable(expected);
  });
});


export function provideMockActions(source: Observable<any>): Provider;
export function provideMockActions(factory: () => Observable<any>): Provider;
export function provideMockActions(factoryOrSource: (() => Observable<any>) | Observable<any>): Provider {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs an integration test

Copy link
Member

@brandonroberts brandonroberts Jul 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add the integration test in the example app after this gets merged

@brandonroberts
Copy link
Member

Review is done. Test in the store spec needs to be fixed since the behavior has changed in Rx

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 88.426% when pulling c84425e on chore/ngrx-effects-testing into d176a11 on master.

@brandonroberts brandonroberts merged commit 7dbb571 into master Jul 12, 2017
@MikeRyanDev MikeRyanDev deleted the chore/ngrx-effects-testing branch July 12, 2017 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants