Giter VIP home page Giter VIP logo

Comments (12)

jamesarosen avatar jamesarosen commented on June 21, 2024

Have you read https://github.com/jamesarosen/ember-i18n/wiki/Doc:-Testing ?

from ember-i18n.

epchristi avatar epchristi commented on June 21, 2024

from ember-i18n.

epchristi avatar epchristi commented on June 21, 2024

Yes. That is what I mentioned when I showed the import --- are there other steps missing? (I notice t is defined)

from ember-i18n.

jamesarosen avatar jamesarosen commented on June 21, 2024

Is that an expected case that should be handled?

Not expected.

And/Or is this a setup issue?

Possibly. It's also possible that ember-i18n's guides for using RFC232/RFC268 tests are wrong.

Perhaps you could share more of your test file.

from ember-i18n.

epchristi avatar epchristi commented on June 21, 2024

On thing that is different (although I tried using module), is we are using moduleForAcceptance to setup the qunit tests. The test itself is pretty simple.

in moduleForAcceptance('Acceptance | dashboard', {
beforeEach() {
// create a mock server for mirage
// create a page
}
});

test('Networks title', async function(assert) {
await(page.visit(...page setup in the beforeEach...));
assert.equal(page.title, t('common.networksText'));
});

ember 2.18 still generates "qunit stubs" that use moduleForAcceptance. I wonder if that's part of the issue.

In my start-app.js helper I do:
let application = Application.create(attributes);
application.setupForTesting(); // tried setupApplicationTest, but that didn't work
application.injectTestHelpers();
return application;

Then in our module-for-acceptance.js helper, it's pretty boiler-plate. this.application= startApp();

from ember-i18n.

jamesarosen avatar jamesarosen commented on June 21, 2024

You're using an "old-style" acceptance test, not an RFC268-style test. That means you should follow this section. Specifically, you should have

// tests/helpers/start-app.js
import './ember-i18n/test-helpers';

and shouldn't have import { t } from 'ember-i18n/test-support' in your test file.

from ember-i18n.

epchristi avatar epchristi commented on June 21, 2024

I am okay with you closing this, however, I still get the "assert" that owner isn't defined. I am going to back down to qunit 4.1.1 to see if using the "old" way works as you suggestion. Thank you.

from ember-i18n.

jamesarosen avatar jamesarosen commented on June 21, 2024

I didn't expect that! Do please document your findings here. We can add them to the wiki once you figure out what's going on.

from ember-i18n.

epchristi avatar epchristi commented on June 21, 2024

I should note, this all worked prior to upgrading to ember 2.18.2

I am now trying with Qunit 4.1.1 -- I can change this out if I should go to 4.2.1

In my start-app.js file, I added:
import './ember-i18n/test-helpers';

Here is what I have so far. In my "test", I am setting it up like this:

import { tHelper } from 'ember-i18n/helper';
import { getOwner } from '@ember/application';

moduleForAcceptance('Acceptance | dashboard', {
    beforeEach() {
        getOwner(this).lookup('service:i18n').set('locale', 'en');
        this.register('helper:t', tHelper);
        ...

First, eslint fails because of t being undefined. If this works, I can put a mirage ignore for those errors, not a huge deal.
Second.. the getOwner fails. This is because getOwner(this) returns undefined.

so.. I tried removing that call.
then, this.register is undefined.

So.. those steps are not working as expected.

from ember-i18n.

jamesarosen avatar jamesarosen commented on June 21, 2024

First, eslint fails because of t being undefined.

You can add t to tests/.eslintrc.js. It's a global test helper like visit or fillIn.

from ember-i18n.

epchristi avatar epchristi commented on June 21, 2024

okay. I backed qunit down to version 4.1.1. I removed all the register stuff and simply added the import to start-apps. I added t: true to globals of .eslintrc.js and now I have it working.

Thank you for your help! (I would close this, but realize there may be an issue with 4.2.1 using the old way.)

from ember-i18n.

jamesarosen avatar jamesarosen commented on June 21, 2024

jamesarosen/ember-i18n has been deprecated in favor of ember-intl.

from ember-i18n.

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.