Skip to content

Mocking directive #3000

Answered by satanTime
grosch asked this question in Q&A
Jul 4, 2022 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

Updated

I think, it has been fixed already by https://github.com/help-me-mom/ng-mocks/releases/tag/v14.1.0, could you verify if it works for you?

Original

In your example, because LinkDirective has been imported by ExampleComponent, and you want to mock it, you should simply use:

const dependencies = MockBuilder(ExampleComponent).build();

I know that docs are hard to read, I'm very sorry for that, simply not much time to improve them.
More info why and how is here: https://ng-mocks.sudo.eu/guides/component-standalone

Anyway, MockBuilder([ExampleComponent], [LinkDirective]).build() shouldn't throw, I'll double check what is wrong there and I'll try to fix it.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@grosch
Comment options

@satanTime
Comment options

@grosch
Comment options

@satanTime
Comment options

@grosch
Comment options

Answer selected by satanTime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants