3
我試圖讓我們的認證(ember-simple-auth
)由Pretender
被嘲笑在我們的測試運行,但由於某種原因,我得到以下錯誤:使用僞裝與Ember CLI
Pretender intercepted POST http://api.dev/token but no handler was defined for this type of request
這裏設置我的那一刻,我login-test.js
module('Integration - Login Page', {
setup: function() {
App = startApp();
server = new Pretender(function(){
this.get('http://api.dev/v1/accounts/current', function(request) {
var response = {
"message": "unauthorized"
};
return [401, { "Content-Type": "application/json" }, JSON.stringify(response)];
});
this.post('http://api.dev/token', function(request) {
var response = {
"access_token": "myaccesstoken==",
"token_type": "bearer"
};
return [200, { "Content-Type": "application/json" }, JSON.stringify(response)];
});
});
},
teardown: function() {
Ember.run(App, App.destroy);
server.shutdown();
}
});
會有人知道爲什麼URL沒有註冊?
我確實有它開始與結尾的斜線,如'/ token',但我有同樣的問題。我很好奇我是否應該將'serverTokenEndpoint'設置爲'/ token',然後將代理設置爲'http:// api.dev'? – alvincrespo
是的,它didi它。我將代理所有請求。感謝bcardarella! – alvincrespo
不幸的是,這個解決方案對我不起作用,我想知道我的情況有什麼不同 – mobetta