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

Feature Request: Never Mock CommonModule standalone directives #5047

Closed
evtk opened this issue Mar 2, 2023 · 4 comments · Fixed by #5075
Closed

Feature Request: Never Mock CommonModule standalone directives #5047

evtk opened this issue Mar 2, 2023 · 4 comments · Fixed by #5075
Assignees
Labels

Comments

@evtk
Copy link

evtk commented Mar 2, 2023

Describe the feature or problem you'd like to solve

I'm currently migrating my Angular app to standalone components and I noticed a lot of UT's failing due to the fact that the standalone Directives from the CommonModule are all mocked.

If you use the CommonModule, this issue doesn't occur, because the CommonModule will never be mocked.

119dd80#diff-681237701f19323be249b4715554476ddf90b5f2f81ebbf06e8a7206344048aa

Proposed solution

Can all the standalone directives from the CommonModule also be excluded from mocking. This will prevent to do a

      .keep(NgIf)
      .keep(NgSwitch)
      .keep(NgSwitchCase)
      .keep(NgFor)
      etc...

in every UT. Many thanks!

Additional context

Posted this on the gitter as well: https://app.gitter.im/#/room/#ng-mocks_community:gitter.im/$B5OT4_mO-IlFcQHZc7Pg_rYyxm-OxSJBdPx1BNPVkAM

@evtk evtk added the enhancement New feature or request label Mar 2, 2023
@satanTime
Copy link
Member

satanTime commented Mar 5, 2023

Hi @evtk,

could you provide an example of a failing test?

As an option, you can use ngMocks.globalKeep(NgIf) to avoid repetitive declarations in different specs.

satanTime added a commit to satanTime/ng-mocks that referenced this issue Mar 5, 2023
satanTime added a commit to satanTime/ng-mocks that referenced this issue Mar 5, 2023
satanTime added a commit that referenced this issue Mar 5, 2023
docs(CommonModule): keeping standalone declarations #5047
@satanTime
Copy link
Member

v14.7.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.

@evtk
Copy link
Author

evtk commented Mar 5, 2023

awesome, many thanks. Works like charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants