Comments (12)
Have you read https://github.com/jamesarosen/ember-i18n/wiki/Doc:-Testing ?
from ember-i18n.
from ember-i18n.
Yes. That is what I mentioned when I showed the import --- are there other steps missing? (I notice t is defined)
from ember-i18n.
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.
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.
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.
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.
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.
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.
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.
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/ember-i18n has been deprecated in favor of ember-intl.
from ember-i18n.
Related Issues (20)
- Adding a `scope` option HOT 3
- Compatibility with fastboot?
- helper creates Ember.Object.extend().create() HOT 3
- emberGetownerPolyfill issue in i18n service HOT 4
- Refactor test helpers
- Passing in multiple translation keys (perhaps to Safely concat them together?) HOT 11
- Setting locale as described fails HOT 2
- switching language locally, not globally HOT 2
- require in get-locales clashes with other locally defined requires HOT 10
- Quest: intent to deprecate HOT 18
- Pluralized do not behave always the same way HOT 7
- Call a translation key dynamically HOT 2
- Getting a language value from locale in a template HOT 4
- Dynamic update of <html lang="en"> with FastBoot support HOT 2
- Interpolating quotes HOT 2
- ;import Service from "ember-i18n/service"; HOT 2
- Babel error HOT 1
- undefined is not an object (evaluating 'this.get('i18n').t') HOT 1
- _locale Computed property is not called more than once HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-i18n.