-
-
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
New warning about unprovided feature state wrecks unit test output #2116
Comments
@Halt001 Could you push up a basic code sample where this is happening? I can try to work around this, possibly by excluding tests, possibly by excluding router state. Thanks! |
Working on it. May take some time as I can't share our code and it isn't obvious to me when the warning is triggered. |
I appreciate your help, thanks! |
Sorry for the delay. I've created a repo with an app that generates the warning multiple times after running the unit tests with Also when running the app with |
I haven't taken an in-depth but it I believe you should also import the router and router-store. In your component you're using a router selector, but no (router) state is provided. |
I've added actual routing to the app. |
@timdeschryver what do we want to do here? The point of this was to save headaches, not create them. Only approach I've found was to string match on the state key for router. I do think it is a valuable warning, though, as I think the comment in the original thread is an unprovided state issue. |
well the error is telling me something is wrong...better than none for instance if you forget to add an index route ' ' in one of your router modules you will get this
which doent tell much about what to do or where to go except guess that url/router might be the cause... that one held me up three days deep into router modules so if this ngrx error is omitted or stifled what would I see then? |
@jtcrowson I have mixed feelings here, the same you are expressing. I don't see any solution neither, besides doing a string match. I'd like to know if it's only the router store that's causing these warnings. |
From my perspective My router store is functioning and running fine and I eluded to race conditions associated with the way developers are cobbling together their lazy loaded and eager loaded modules as they are setting up at bootstrap according to their route tree I am ironing out my router tree now in some cases ngrx is ok and gets past the anomalous setup of modules beit eager/lazy in other cases the message appears identifying the anomalous setup of modules beit eager/lazy and the reference error occurs |
Thanks for the info @meanstack-perficient |
We're having a similar issue with many user-defined feature modules where the state is intentionally |
I like that idea @aquark 👍! |
try to select the router slice of state with a simple function
because createFeatureSelector, hence the name, is used for selecting a slice of state added
in this case you should use createFeatureSelector
|
We have unit tests where we use the state without mocking. With the new warning about undefined feature state, that is given while it shouldn't in case of the router state, our unit test are now littered with this warning. Also it shows up in the debugger console when we run the app.
Warning:
Also see the discussion here: Issue 1897
Expected behavior:
I think it is bad practice to give warnings that should be ignored in some cases. This leads to warning/error fatigue. Also unit tests that have hundreds or even thousands of warnings quickly lose their usefulness.
So please find a way to not warn when there is nothing to warn about, like in the case of the router state. Or add the ability to suppress the warnings for a user provided key, or even remove this warning completely as it does seem to do more harm than good.
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):
NgRx 8.3
Ng 8.2.5
The text was updated successfully, but these errors were encountered: