統合テストを作成するために QUnit で ember.js をセットアップしようとしています。
http://emberjs.com/guides/testing/integration/の指示に従ってください:
document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
App.rootElement = '#ember-testing';
App.setupForTesting();
App.injectTestHelpers();
module("Integration Tests", {
setup: function() {
App.reset();
}
});
test("root lists first page of posts", function(){
visit("/").then(function() {
equal(find(".post").length, 5, "The first page should have 5 posts");
// Assuming we know that 5 posts display per page and that there are more than 5 posts
});
});
ただし、QUnit を実行すると、次のエラーが発生します。
Assertion failed: You have turned on testing mode, which disabled the
run-loop's autorun. You will need to wrap any code with asynchronous
side-effects in an Ember.run
現在のユーザー セッションがあるかどうかを確認するために、アプリの初期化子で http 要求を作成しているため、このアサーション エラーがトリガーされます。有効なユーザーが存在しない場合、これは 401 エラーを返します。(アプリがこの要求に対して常に 200 を返すように強制すると、このアサーション エラーは発生せず、テストは期待どおりに続行されます)。
無効なユーザーに対して http エラーを返すことで、アプリと API が正しく動作していると信じており、テストを機能させるためだけに 200 への応答に変更したくありません。ember と QUnit で http エラーとアサーションを処理するにはどうすればよいですか? 私が読んだことから、 で何かをラップする必要がありますがEmber.run
、何がわかりません。