Ember-intl: Can't access intl service in addon tests and dummy app

Created on 17 Jun 2019  路  2Comments  路  Source: ember-intl/ember-intl

I'm extending the intl service in my addon but when I try to access it in the tests I can only access the original service. However it works when consuming it in the app. It also worked when I had it extended in the app so the issue is only in the addon.

import Service from 'ember-intl/services/intl';

export default Service.extend({
  currentLocale: 'en'
});

Environment

  • Ember Version: 3.10.1
  • Ember CLI Version: 3.10.0
  • Ember Intl Version: 3.5.2
  • Browser(s): All
  • Node Version: 10.15.3

Steps to Reproduce

Extend the intl service in the addon and add a simple attribute like currentLocale: 'en'. Try to access that in the dummy app. Also try to access it in an integration test like

let service = this.owner.lookup('service:intl');
service.currentLocale

Also accessing the intl service in unit tests work only like this

import IntlService from 'my-addon/services/intl';
let service = IntlService.create(this.owner.ownerInjection());

question

Most helpful comment

ember-intl does not do anything out of the ordinary in registering the service.

You likely need to tell ember-cli to use your addon's app tree over ember-intl's app tree. Right now, it just sounds like ember-intl's app tree is winning out.

That can be fixed in your addon's package.json via:

{
 "ember-addon": {
    "after": ["ember-intl"]
  }
}

If this doesn't resolve it, I'd need a working reproduction of the issue that I can clone and look at.

All 2 comments

ember-intl does not do anything out of the ordinary in registering the service.

You likely need to tell ember-cli to use your addon's app tree over ember-intl's app tree. Right now, it just sounds like ember-intl's app tree is winning out.

That can be fixed in your addon's package.json via:

{
 "ember-addon": {
    "after": ["ember-intl"]
  }
}

If this doesn't resolve it, I'd need a working reproduction of the issue that I can clone and look at.

Thanks a lot, this was exactly the issue and it's now solved 馃檱 Closing...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

richard-viney picture richard-viney  路  5Comments

dbendaou picture dbendaou  路  4Comments

mansona picture mansona  路  5Comments

Kilowhisky picture Kilowhisky  路  4Comments

jacobq picture jacobq  路  6Comments