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

Store: add ability to create the Store/MockStore outside of the TestBed #2745

Closed
brandonroberts opened this issue Oct 17, 2020 · 2 comments · Fixed by #2759
Closed

Store: add ability to create the Store/MockStore outside of the TestBed #2745

brandonroberts opened this issue Oct 17, 2020 · 2 comments · Fixed by #2759

Comments

@brandonroberts
Copy link
Member

Currently you have to use the TestBed provideMockStore() to get an instance of the MockStore. This would declare static providers when using provideMockStore() so it can be used with Injector.create()

Describe any alternatives/workarounds you're currently using

Other information:

If accepted, I would be willing to submit a PR for this feature

[ ] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No

@amartinelli12
Copy link

I managed to achieve this in my project by the following:

import { ActionsSubject } from '@ngrx/store';
import { MockState, MockStore } from '@ngrx/store/testing';

// import local application state model
// import local application state object

const actionSubject$: ActionSubject = new ActionsSubject();
const reducerManager$: ReducerManager = new ReducerManager(null, null, null, () => null); // this could be improved
const mockState$: MockState<LocalApplicationStateModel> = new MockState();

export const MOCK_STORE$: MockStore<LocalApplicationStateModel> = new MockStore(
    mockState$,
    actionSubject$,
    reducerSubject$,
    LOCAL_APPLICATION_STATE_OBJECT
);

@alex-okrushko
Copy link
Member

Hey @amartinelli12

Checkout the PR from @markostanimirovic that's attached here: #2759
It's good 🙂

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 a pull request may close this issue.

3 participants