Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upDocs: Use async method when testing effects without TestBed #2449
Labels
Comments
|
@MrCube42 what are you proposing in terms of docs, as we don't have any Jest-specific examples in the testing guide. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Background
I decided to test my effects without using the Angular TestBed because this should be faster then using the entire TestBed when I only want to test the effect in isolation (https://ngrx.io/guide/effects/testing#setup-without-testbed). I am using Jest as test runner.
Repro-Steps
Consider this simplified, generic approach I used.
What's the problem?
Unfortunately the test is green, however the coverage showed me that it is not executed properly. This is due to two problems:
How to fix it? What do change?
If the test itself was run inside of
async, then we would know that actually the service'sgetMyDatahas never been called because of the wrong implementation of the mock.The docs may propose to wrap the async test into the
asyncmethod call like this:Side Note
The test itself can than be fixed by don't mocking out the call by jest, but letting it go through.
Instead of using this:
We must use this:
Other information:
I would be willing to submit a PR for the docs❤️
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No