You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
Current behavior
I have a component which use *ngxPermissionsOnly in its template, so in the UT i've used NgxPermissionsAllowStubDirective/NgxPermissionsRestrictStubDirective
I have another component which also use *ngxPermissionsOnly in its template.
Everything used to work perfectly until now that one of the component is a sub component of the other.
When I run tests, I have the following error in the parent component unit tests :
Failed: Uncaught (in promise): NullInjectorError: R3InjectorError(DynamicTestModule)[NgxPermissionsService -> NgxPermissionsService]:
NullInjectorError: No provider for NgxPermissionsService!
NullInjectorError: R3InjectorError(DynamicTestModule)[NgxPermissionsService -> NgxPermissionsService]:
NullInjectorError: No provider for NgxPermissionsService!
Expected behavior
Test should not fail
Minimal reproduction of the problem with instructions
Component A template:
<div *ngxPermissionsOnly="whatEver">
test
</div>
<componentB></componentB>
Angular version: ~9.1.11
ngx-permissions version: ~7.0.3
Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
The text was updated successfully, but these errors were encountered:
Lempkin
changed the title
Mock NgxPermissionsService in component and subcomponent
Mock NgxPermissionsService in component and subcomponent doesn't work
Aug 4, 2020
All we needed was our tests to pass again. Since they didn't rely on any permissions, providing a NEVER observable was sufficient for us. In order to properly mock the permission library you'll have to add proper values for the NgxRolesService.roles$ and NgxPermissionsService.permissions$ observable. (eg. using the rxjs helper of(...)).
Please note: We're using jest, so your mock setup might differ depending on your test runner.
Hopefully this issue is resolved soon, so we can remove those internal mocks again. 🙏
I'm submitting a...
Current behavior
I have a component which use *ngxPermissionsOnly in its template, so in the UT i've used NgxPermissionsAllowStubDirective/NgxPermissionsRestrictStubDirective
I have another component which also use *ngxPermissionsOnly in its template.
Everything used to work perfectly until now that one of the component is a sub component of the other.
When I run tests, I have the following error in the parent component unit tests :
Expected behavior
Test should not fail
Minimal reproduction of the problem with instructions
Component A template:
Component B template:
Component A .spec.ts :
Component B .spec.ts :
Environment
The text was updated successfully, but these errors were encountered: