This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 183
Doc: Testing
James Alexander Rosen edited this page Jun 25, 2015
·
14 revisions
Ember-I18n should work just fine with tests that call startApp
.
When testing components that rely on translated content, the recommended approach is to use an integration-style component test:
moduleForComponent("my-component", "MyComponent", {
integration: true,
beforeEach: function() {
this.set('foo', 'bar');
this.render('{{#my-component}}{{t "some.foo" foo=bar}}{{/my-component}}');
};
}
});
These tests don't run initializers, though, so there are two things you may have to do to get such a test working:
- set
i18n.locale
- register the
t
helper
Ember-I18n requires many things to be available in the Registry
, which makes it difficult to use in unit tests. At a minimum, you would have to declare
needs: [
'service:i18n',
'helper:t',
'locale:xy/translations'
]
and then set i18n.locale
and register the t
helper.
If you find yourself writing lots of unit tests that rely on ember-i18n and find a way to ease this pain, this project would welcome contributions!