question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

this.inject.service(...) is not working

See original GitHub issue
describe('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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Turbo87commented, Jun 5, 2018
0reactions
ming-codescommented, Jun 5, 2018

Yup, that’s it.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found