Coder Social home page Coder Social logo

Comments (2)

heathharrelson avatar heathharrelson commented on June 26, 2024

It turns out to be possible to do this, but it's a little tricky. You can inject the i18n service into the integration test and configure it in the beforeEach() function. Because beforeEach and afterEach apparently don't respect promises (see rwjblue/ember-qunit#192) you have to use assert.async to wait for initialization to finish:

moduleForComponent('some-component', 'Integration | Component | some component', {
  integration: true,

  beforeEach(assert) {
    const done = assert.async();
    this.inject.service('i18n');
    this.get('i18n').initLibraryAsync().then(done);
  }
});

You will probably also want to adjust the i18nextOptions for the test environment to set and preload the initial language as well.

I'll document how this works before releasing the latest version later this week. I haven't looked at trying to create a test helper that initializes i18next yet, but it may be possible.

from ember-i18next.

heathharrelson avatar heathharrelson commented on June 26, 2024

For future reference, the full list of links I used to figure this out:

https://github.com/jamesarosen/ember-i18n/wiki/Doc:-Testing#integration-tests
emberjs/ember-test-helpers#114
https://github.com/rwjblue/ember-qunit/issues/192

from ember-i18next.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.