Injecting services for component integration tests doesn't seem to work
See original GitHub issueThe following code using this.inject.service
never seems to inject the service into the component before trying to render.
/* jshint expr:true */
import { expect } from 'chai';
import {
describeComponent,
it
} from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';
describeComponent(
'provider-options',
'Integration: ProviderOptionsComponent',
{
integration: true
},
function() {
it('renders', function() {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });
// Template block usage:
// this.render(hbs`
// {{#provider-options}}
// template content
// {{/provider-options}}
// `);
this.inject.service('i18n'); // <= This doesn't seem to inject the i18n service
this.render(hbs`{{provider-options}}`);
expect(this.$()).to.have.length(1);
});
}
);
Issue Analytics
- State:
- Created 8 years ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
ember.js - Service not injected into component's integration test
So I tried to inject the service manually into the component and the test worked. This is, however, only partial solution since it...
Read more >Integration tests in ASP.NET Core | Microsoft Learn
Integration tests confirm that two or more app components work together to produce an expected result, possibly including every component ...
Read more >authenticateSession in integration tests? · Issue #1285 - GitHub
This component injects the session service, meaning I would like to be able to test the served content both when signed in and...
Read more >14. Integration Testing - Spring
When the TestContext framework loads your application context, it can optionally configure instances of your test classes via Dependency Injection. This ...
Read more >Integration Testing in Azure Functions with Dependency ...
I'm a big proponent of integration and functional tests (or “subcutaneous tests” if there's a UI). Done efficiently and sparingly, ...
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.inject.service
is only available in tests, and injects the instance ofservice:i18n
into the test context (not the component(s) under test).Your component would still need
i18n: Ember.inject.service()
in it also.Yeah, I think I prefer just injecting it manually. I’m all for self-documenting code, and doing this in 1 line versus 2 in every test is a no brainer.