Skip to content
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

MockStore selectors resulting in warning logs #2363

Closed
timdeschryver opened this issue Feb 10, 2020 · 3 comments · Fixed by #2513
Closed

MockStore selectors resulting in warning logs #2363

timdeschryver opened this issue Feb 10, 2020 · 3 comments · Fixed by #2513
Labels
Accepting PRs community watch Someone from the community is working this issue/PR Project: Store

Comments

@timdeschryver
Copy link
Member

Minimal reproduction of the bug/regression with instructions:

Currently all the tests that use a mockstore with mocked selectors, will log the warning that the state does not exists.

This is normal because when we define a mocks store, we don't define the state object.

Expected behavior:

It should not be logged while running tests.

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):

Angular 9
NgRx 9-beta.1

Other information:

AFAIK, it isn't possible to detect when we run in a test environment.
But we could set a property on the state (__ngrxMockEnvironment__), and the createFeatureSelector could use this property to check if it the warning has to logged or not.

I would be willing to submit a PR to fix this issue

[ ] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No

@evgenyfedorenko
Copy link
Contributor

I can take this one.

@evgenyfedorenko
Copy link
Contributor

@timdeschryver can you please give me the example of the test which produces that warning?

@timdeschryver
Copy link
Member Author

@evgenyfedorenko the example tests log them, run

yarn test:example

evgenyfedorenko added a commit to evgenyfedorenko/platform that referenced this issue Mar 2, 2020
evgenyfedorenko added a commit to evgenyfedorenko/platform that referenced this issue Mar 4, 2020
evgenyfedorenko added a commit to evgenyfedorenko/platform that referenced this issue May 3, 2020
evgenyfedorenko added a commit to evgenyfedorenko/platform that referenced this issue May 3, 2020
evgenyfedorenko added a commit to evgenyfedorenko/platform that referenced this issue May 3, 2020
evgenyfedorenko added a commit to evgenyfedorenko/platform that referenced this issue May 6, 2020
evgenyfedorenko added a commit to evgenyfedorenko/platform that referenced this issue May 10, 2020
evgenyfedorenko added a commit to evgenyfedorenko/platform that referenced this issue May 10, 2020
BioPhoton pushed a commit to BioPhoton/platform that referenced this issue Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepting PRs community watch Someone from the community is working this issue/PR Project: Store
Projects
None yet
2 participants