3
我們使用Ember Data並有RestAdapter
,但我們不想在我們的測試中使用它。 如何在我的驗收測試中將application:adapter
替換爲DS.FixtureAdapter
?如何在我的驗收測試中用`DS.FixtureAdapter`替換`application:adapter`?
我們使用Ember Data並有RestAdapter
,但我們不想在我們的測試中使用它。 如何在我的驗收測試中將application:adapter
替換爲DS.FixtureAdapter
?如何在我的驗收測試中用`DS.FixtureAdapter`替換`application:adapter`?
您應該可以在容器中重新註冊它。
App.__container__.register('adapter:application', DS.FixtureAdapter);
而取決於你如何運行你的測試,你可以,如果你打電話App.reset()
能夠把直接在App命名空間。
App.ApplicationAdapter = DS.FixtureAdapter;
不幸的是沒有這些工作:註冊不做任何事情,應用程序不公開ApplicationAdapter – jasalguero
您可能需要先調用'unregister'。儘管如此,很難確定你的問題。你能否詳細說明你如何測試應用程序?也許給一個樣本測試? – GJK
該應用程序正在使用EmberApp Kit,測試與此處完全相同:https://github.com/stefanpenner/ember-app-kit-todos/blob/master/tests/acceptance/todos_test.js主要的區別是在那個項目中,他們從一開始就使用FixtureAdapter,所以他們不必切換 – jasalguero