-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Question: Mocking structural directive that's a part of a module #971
Comments
Hi @DmitryEfimenko, Thanks for the question. What you wrote is all true and there is not other way currently. However, I'll take a look what is possible here. Maybe, something like with route guards or http interceptors, or ngMocks.defaultConfig. Issues appear when a structural directive requires a context, then simply passing 'render: true' isn't enough. But, I think, if you were needed only to define contexts for such directives, it would still require less configuration than at the moment. Let's keep the issue open as a feature request. I'll implement it in some weeks and will be pinging you for your feedback time to time. |
could you also describe how you would imagine its usage / implementation from your point of view? |
thanks for a quick reply! Glad my question might result in a new feature for ng-mocks! Not sure if the following would be possible: const dependencies = MockBuilder()
.mock(ModuleThatContainsDirective)
.mock(DirectiveIncludedInTheModuleAbove, { render: true, /* any other config */ }) The idea here is similar to the functionality described here. |
Hm... actually the example you gave is exactly as it should be used currently: https://ng-mocks.sudo.eu/api/MockBuilder#render-flag I think I'm missing something. |
then it must be either a bug or I'm doing something wrong. Let me see if I can create a repro |
Thee is an example on stackblitz / codesandbox: https://ng-mocks.sudo.eu/guides/directive-structural Looks like it's a potential bug. |
Ah. A wrong link sorry |
Ha. yeah. I guess we need at least to cover it as a separate test in However, I'm not 100% sure it's exactly what you have. |
I must have done something wrong in my other project at work today. For now, I can't reproduce the issue. Here's my attempt. I'll poke around in the other project tomorrow and see if I can spot something weird. But for now, I'll assume I did something weird and close the issue. I'll reopen it if I find something out! Thanks again! |
Sounds good, happy coding! |
as a minor comment for docs improvement, the |
Let's keep it as a feature request for global config for all directives in a module. |
feat(ngMocks.defaultConfig): config for MockBuilder #971
v13.2.0 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems. |
Hi @DmitryEfimenko, I hope you and your relatives and friends are safe. I fixed types for |
Thank you for the kind words! Everything is all right here. I wish the same for you and your family. Love it! I'll be sure to get the latest version and give it a spin! |
I have a structural directive that's used in the component under test. When simply mocked using
MockDirective(MyDirective)
orMockBuilder.mock(MyDirective)
, it does not render the contents. I know, I can pass a configuration object{ render: true }
to make it render. However, that directive is a part of a module that's being mocked. Here's how my mocks look like:I know that I could
mock
all the things from theTheModuleThatContainsDirectiveAndOtherThings
separately and use the{ render: true }
on the directive, but that seems inefficient:Is there a way to configure the directive to render content with a shorter syntax?
The text was updated successfully, but these errors were encountered: