You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User should be able to override selector result with undefined too, at this moment undefined value is indicating that the selector result is not overwritten, thus mockstore will try to run all the selector logic.
This would be useful in case of a deep state contains an optional value and the user do not want to define the whole state tree in the parameter of the provideMockStore method. As a workaround setResult can be called with null as any, but projects can ban null keyword via a tslint rule, thus it might requires additional lint ignore comment too.
NgRx should use a different variable for indicating is the selector value overwritten.
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):
NgRx: 8.4.0
I would be willing to submit a PR to fix this issue
[X] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered:
Wow, I had to spend a couple of hours in order to find this issue and realize that overrideSelector() does not properly handle the undefined value. Indeed, this is a huge problem and has to be fixed
Closes#2244
BREAKING CHANGE:
BEFORE:
Using `mockSelector.setResult(undefined)` resulted in clearing the
return value.
AFTER:
Using `mockSelector.setResult(undefined)` will set the return value of
the selector to `undefined`.
To reset the mock selector, use `mockSelector.clearResult()`.
Minimal reproduction of the bug/regression with instructions:
Expected behavior:
User should be able to override selector result with
undefined
too, at this momentundefined
value is indicating that the selector result is not overwritten, thus mockstore will try to run all the selector logic.This would be useful in case of a deep state contains an optional value and the user do not want to define the whole state tree in the parameter of the
provideMockStore
method. As a workaroundsetResult
can be called withnull as any
, but projects can ban null keyword via a tslint rule, thus it might requires additional lint ignore comment too.NgRx should use a different variable for indicating is the selector value overwritten.
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):
NgRx: 8.4.0
I would be willing to submit a PR to fix this issue
[X] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered: