3

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?

alvincrespo
  • 9,224
  • 13
  • 46
  • 60

1 Answers1

1

Remove the http://api.dev if you are using the server proxy

bcardarella
  • 4,667
  • 4
  • 29
  • 45