J'ai un test d'intégration simple et sans os pour un composant qui dépend d'un service i18n
(que le test injecte). Le composant lui-même est un menu déroulant de sélection simple de ember-select-list
, avec une valeur par défaut de Select Language
. Voici le test:Pourquoi mon test d'intégration du composant Ember est-il réussi lorsque je l'exécute de manière isolée, mais échoue lorsque j'exécute la suite complète?
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('language-select', 'Integration | Component | language select', {
integration: true,
beforeEach() {
this.inject.service('i18n');
}
});
test('it renders', function(assert) {
this.render(hbs`{{language-select}}`);
assert.equal(this.$().text().trim().includes('Select Language'), true);
});
Lorsque je tente d'exécuter ce seul fichier de test (c.-à-ember test -f "language-select"
), la sortie que je vois indique que sont effectués les tests que peluchage:
[ hospitalrun-frontend ] $ ember test -f "language-select"
WARNING: Node v7.5.0 is not tested against Ember CLI on your platform. We recommend that you use the most-recent "Active LTS" version of Node.js.
cleaning up...
Built project successfully. Stored in "/Users/richie.thomas/Desktop/Workspace/OpenSource/hospitalrun-frontend/tmp/core_object-tests_dist-5MT1adu7.tmp".
ok 1 PhantomJS 2.1 - ESLint - acceptance/language-select-test.js: should pass ESLint
ok 2 PhantomJS 2.1 - ESLint - components/language-select.js: should pass ESLint
ok 3 PhantomJS 2.1 - TemplateLint - hospitalrun/templates/components/language-select.hbs: should pass TemplateLint
ok 4 PhantomJS 2.1 - ESLint - integration/components/language-select-test.js: should pass ESLint
1..4
# tests 4
# pass 4
# skip 0
# fail 0
# ok
Cependant quand je lance un plaine ember test
, je vois que ce test échoue parce que je suis injectais apparemment le service i18n mal:
not ok 488 PhantomJS 2.1 - Integration | Component | language select: it renders
---
actual: >
null
expected: >
null
stack: >
http://localhost:7357/assets/hospitalrun.js:4090:18
[email protected]://localhost:7357/assets/vendor.js:35757:32
[email protected]://localhost:7357/assets/vendor.js:40664:22
[email protected]://localhost:7357/assets/vendor.js:33758:29
[email protected]://localhost:7357/assets/vendor.js:33625:52
[email protected]://localhost:7357/assets/vendor.js:65639:37
[email protected]://localhost:7357/assets/vendor.js:33512:34
[email protected]://localhost:7357/assets/vendor.js:31495:53
[email protected]://localhost:7357/assets/vendor.js:66320:43
[email protected]://localhost:7357/assets/vendor.js:72898:36
[email protected]://localhost:7357/assets/vendor.js:72472:30
[email protected]://localhost:7357/assets/vendor.js:30793:52
[email protected]://localhost:7357/assets/vendor.js:41756:28
[email protected]://localhost:7357/assets/vendor.js:31058:64
[email protected]://localhost:7357/assets/vendor.js:31096:26
[email protected]://localhost:7357/assets/vendor.js:31017:35
[email protected]://localhost:7357/assets/vendor.js:30930:23
[email protected]://localhost:7357/assets/vendor.js:30913:29
[email protected]://localhost:7357/assets/vendor.js:19795:19
[email protected]://localhost:7357/assets/vendor.js:19865:15
[email protected]://localhost:7357/assets/vendor.js:19989:20
[email protected]://localhost:7357/assets/vendor.js:20059:28
[email protected]://localhost:7357/assets/vendor.js:20182:19
[email protected]://localhost:7357/assets/vendor.js:40972:32
[email protected]://localhost:7357/assets/test-support.js:20665:30
http://localhost:7357/assets/tests.js:15398:16
[email protected]://localhost:7357/assets/test-support.js:3859:34
[email protected]://localhost:7357/assets/test-support.js:3845:13
http://localhost:7357/assets/test-support.js:4037:15
[email protected]://localhost:7357/assets/test-support.js:3522:26
[email protected]://localhost:7357/assets/test-support.js:5213:27
http://localhost:7357/assets/test-support.js:4407:11
message: >
Died on test #1 http://localhost:7357/assets/tests.js:15392:24
[email protected]://localhost:7357/assets/vendor.js:123:37
[email protected]://localhost:7357/assets/vendor.js:38:25
[email protected]://localhost:7357/assets/test-support.js:19547:14
[email protected]://localhost:7357/assets/test-support.js:19539:21
[email protected]://localhost:7357/assets/test-support.js:19569:33
http://localhost:7357/assets/test-support.js:7584:22: undefined is not an object (evaluating 'i18n.get')
Log: |
...
Je ne vois rien dans le documentation here sur l'indicateur de filtre affectant le type de tests qui sont exécutés (c.-à-d. essais de peluches et de non-peluches).
Je suis heureux de poser une question distincte sur la façon d'injecter correctement le service i18n, mais ma question ici est:
Pourquoi ajouter le résultat du drapeau filter
dans les tests de filtrage ne en cours d'exécution?
OK, cela a bien fonctionné comme prévu. Merci! Cependant puisque 'language-select' est le premier paramètre de l'appel de méthode' moduleForSelect', cela ne signifie-t-il pas que le nom du module est défini sur 'language-select'? Si c'est vrai, je m'attendrais à ce que le trait d'union ne soit pas un problème. –
Non, le deuxième argument est nom. –