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

Bug: Angular 16 ngMocks.findInstance swallows original error #7041

Closed
CSchulz opened this issue Oct 20, 2023 · 2 comments · Fixed by #7442
Closed

Bug: Angular 16 ngMocks.findInstance swallows original error #7041

CSchulz opened this issue Oct 20, 2023 · 2 comments · Fixed by #7442
Assignees
Labels
bug Something isn't working released v14.12.0

Comments

@CSchulz
Copy link

CSchulz commented Oct 20, 2023

Description of the bug

If there is an error with the provider factory during the tests ngMocks.findInstance swallows the original error and shows Cannot find an instance via ngMocks.findInstance(...) only.
This requires debugging into ng-mocks to find the root cause.

An example of the bug

https://stackblitz.com/edit/github-6z37vt?file=src%2Ftest.spec.ts

Expected vs actual behavior

Expected: Show also the original error if there is one.

Cannot find an instance via ngMocks.findInstance(...). Caught an error during the injection call: <original error>.

Actual: Cannot find an instance via ngMocks.findInstance(...)

@satanTime
Copy link
Member

Hi @CSchulz,

thanks for reporting the issue. It will be fixed with the next release.

satanTime added a commit that referenced this issue Nov 15, 2023
fix(ngMocks): respects custom errors on lookups #7041
@satanTime
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released v14.12.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants