-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
MockStore .setResult() does not emit on observable #2000
Comments
@pburkindine I don't see the |
@jtcrowson D'oh! Try again please :D |
To trigger a state change, you must set a new store result. it('should updata the message', () => {
fixture.detectChanges();
expect(fixture.nativeElement.innerHTML.includes('one')).toBeTruthy();
actions.getMessage.setResult('two two');
store.setState({});
fixture.detectChanges();
expect(fixture.nativeElement.innerHTML.includes('two two')).toBeTruthy();
}); |
I'm sorry, but I don't know why this was closed. Tests included in the repo by @pburkindine still don't pass, even after setting new state, as described by @timdeschryver. I'm having exactly same issue with my unit tests in my projects. |
The suggestion shown by @timdeschryver works for me. Make sure to call store.setState() and fixture.detectChanges(). |
Hey @brianguppy, also checkout |
MockStore
mock selectors created withoverrideSelector
do not emit on the stream when.setResult
is calledThis is essential functionality for testing long-lived streams, e.g.
| async
streams, and replacing Store in component testsIf another approach is preferred, it needs to be indicated in the documentation
Minimal reproduction of the bug/regression with instructions:
https://github.com/pburkindine/ngrx-mockstore-setresult
ng test
to see the third test insrc/app/sample-component/sample-component.component.spec.ts
failsExpected behavior:
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):
Angular: 8
NgRx: 8
Node: 10
OS: OSX High Sierra
I would be willing to submit a PR to fix this issue
[ ] Yes (Assistance is provided if you need help submitting a pull request)
[X] No
The text was updated successfully, but these errors were encountered: