DEV Community

Discussion on: How to Test Five Common NgRx Effect Patterns

Collapse
 
lmfinney profile image
Lance Finney

Two thoughts:

  1. I find it interesting that you seem to default to marbles, but switch to direct subscription only when necessary. I personally go in the opposite direction. Do you think there's a solid reason for your approach, or is it more personal preference?
  2. One of the situations where I abandon subscription for marbles is when I have a filter in my effect. I haven't figured out a satisfying way to test an Observable that doesn't ever emit anything, except through a marble test that asserts a cold('') result. If you build upon this article in the future (or if Brandon snaps it up for NgRx documentation), that might be a good 6th pattern to add.
Collapse
 
jdpearce profile image
Jo Hanna Pearce
  1. It's just something I'm used to - I think marbles tests maybe look a little neater? I did consider rewriting this to ignore marbles entirely though.

  2. For filters and testing with subscriptions I'd just do what I did in the last pattern and then ensure that output is still undefined. Testing for a negative is always going to be a bit flaky though, imo.