-
-
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
docs(effects): rewrite testing #1974
Conversation
bf3b45c
to
54da821
Compare
Thanks for the feedback @itayod , I reworded some sentences in the last commit. |
54da821
to
1cbf421
Compare
Preview docs changes for 54da821 at https://previews.ngrx.io/pr1974-54da821/ |
LGTM! 👍 |
Preview docs changes for 1cbf421 at https://previews.ngrx.io/pr1974-1cbf421/ |
@timdeschryver Is there also a full example of the (non-testbed) source code available? |
// other providers | ||
], | ||
}); | ||
For a detailed look on the marble syntax, see [Writing marble tests](https://github.com/ReactiveX/rxjs/blob/master/doc/writing-marble-tests.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a detailed look on the marble syntax, see [Writing marble tests](https://github.com/ReactiveX/rxjs/blob/master/doc/writing-marble-tests.md). | |
For a detailed look on the marble syntax, see [Writing marble tests](https://rxjs.dev/guide/testing/marble-testing). |
) | ||
); | ||
// verify the navigation has been called | ||
expect(router.navigateByUrl).toHaveBeenCalledWith('customers/bob'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example should include spying on the router.navigateByUrl
method
|
||
Leverage [`MockStore`](/guide/store/testing#using-a-mock-store) and [`MockSelectors`](/guide/store/testing#using-mock-selectors) to test Effects that are selecting slices of the state. | ||
|
||
An example of this is to not fetch an entity (customer in this case) when it's already in the store state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still need to include an effects example that you are testing against here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an example at https://ngrx.io/guide/effects#incorporating-state.
I didn't add any effects code in the testing guide, only how to test them.
If we add an effects example for this test, we should add them for the rest too.
Thoughts?
Preview docs changes for f23c4ce at https://previews.ngrx.io/pr1974-f23c4ce/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. One minor change
Co-Authored-By: Brandon <robertsbt@gmail.com>
Preview docs changes for 2d3c2fc at https://previews.ngrx.io/pr1974-2d3c2fc/ |
@yluijten You can find examples at https://github.com/vsavkin/testing_ngrx_effects and https://github.com/tomastrajan/angular-ngrx-material-starter |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Part of #1383
What is the new behavior?
Does this PR introduce a breaking change?
Other information