初めてモカテストを学ぼうとしています。次のような簡単なテスト スクリプトを作成しました。
describe('Analytics Test Suite', function(){
//http://emberjs.com/guides/testing/integration/
before(function() {
AS.rootElement = '#ember-application-container';
AS.setupForTesting();
AS.injectTestHelpers();
AS.reset();
});
describe('visit analytics index page', function(){
visit("/analytics").then(function() {
it('should return -1 when the value is not present', function(){
expect([1,2,3].indexOf(4)).to.be(-1);
expect([1,2,3].indexOf(0)).to.be(-1);
})
});
})
});
しかし、私はこのjsエラーを受け取ります:
ReferenceError: 訪問が定義されていません
しかし、コードを次のように変更すると:
describe('Analytics Test Suite', function(){
AS.rootElement = '#ember-application-container';
AS.setupForTesting();
AS.injectTestHelpers();
AS.reset();
describe('visit analytics index page', function(){
visit("/analytics").then(function() {
it('should return -1 when the value is not present', function(){
expect([1,2,3].indexOf(4)).to.be(-1);
expect([1,2,3].indexOf(0)).to.be(-1);
})
});
})
});
これらのエラーが発生します: TypeError: app._ container _.lookup(...) is undefined
最初のシーンでは、visit 関数が欠落しているように見えますが、これは初期化コードを before の外に置くと解決されます。しかし、タイプ エラーが発生します。AS._コンテナー_lookupを探すべきだったと思いますが、アプリの名前空間を調べています。私はemberデバッグバージョンhttp://builds.emberjs.com/tags/v1.0.0/ember.jsを使用しています
あなたの助けは大歓迎です。jsbin http://jsbin.com/ILUbuy/2/も追加しました。
ありがとう、ディー
更新 このアダプターを追加して問題を解決しました:https://github.com/teddyzeenny/ember-mocha-adapter