this.inject.service(...) is not working
See original GitHub issuedescribe('Unit @ validator:user/roles', function() {
setupTest('validator:user/roles', {
needs: ['validator:messages', 'service:store']
});
it('should detect user with no roles.', async function() {
this.inject.service('store');
console.log(this.store); // nope
});
});
Investigation shows that this
is not the instance of context
that inject is setting to. So injection is working…just on the wrong object.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Angular 2 Dependency Injection not working - Stack Overflow
The constructor is missing a body {} and is therefore ignored. You only need @Injectable() if the class' constructor has parameters. In this ......
Read more >Testing Dependency Injection • Angular - codecraft.tv
When the component is created since it has its own injector it will resolve the AuthService itself and not forward the request to...
Read more >TestBed.configureTestingModule, will this inject service into ...
Question is from the console.log, I suspect the electron service is not being injected at all. Why is that so? When TestBed.createComponent( ...
Read more >Dependency Injection - Microsoft Learn
The dependency injection container is great for creating view model instances. If a view model has dependencies, it will handle the creation and ......
Read more >Testing services - Angular
To check that your services are working as you intend, you can write tests specifically for them. If you'd like to experiment with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this?
Yup, that’s it.