Integration Test for Component with dependencies on a addon


#1

I have a dependency with our internal addon where I’m injecting our json-api-resource to an integration test to ‘wrap’ a mirage fixture. The said dependency is a resource where it needs a injected service (from within the addon) for a computed property. The problem is when I run the test the computed property gets a undefined value from the injected service. Is there a way to load an ember addon when performing an integration test? Is there a better way to perform this test?


#2

How about a test helper to mock the service?


#3

Thanks for the reply. What I was missing was injecting the service in the component. The following code:

this.registry.register('service:app-meta', appMeta, { as: 'appMeta' });
this.registry.register('model:loan-applications', loanAppResource, { instantiate: false });
this.registry.injection('model', 'appMeta', 'service:app-meta');
this.subject = function(options) {
let Factory = owner.lookup('model:loan-applications');       
    return Factory.create(options);
};

The lines that fixed it for me is the one with ‘registry.injection’