I am trying to get our authentication ( ember-simple-auth
) to be mocked by Pretender
to run in our tests, but for some reason I get the following error:
Pretender intercepted POST http://api.dev/token but no handler was defined for this type of request
Here is the setup I have at the moment in my 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();
}
});
Would anyone know why the url is not registering?
如果您使用的是服务器代理,请删除http://api.dev
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.