Search code examples
ember.jsember-cli-mirage

Ember Mirage Fake API test with Postman


I have my mirage setup which returns data on my defined models, for example if I call /api/users: it returns me all the fake users I need. If I take the same call and test it on Postman, it returns nothing? I thought mirage is acting like a fake API end point server and testing it with Postman will work. Am I missing anything here?


Solution

  • Mirage is only intercepting AJAX and fetch requests in the current browser window. It's using pretender library therefor, which replaces the native XMLHttpRequest object to achieve that one. This is not affecting any other browser window or addon. Therefore you can't query the mock API using Postman or any other client outside of current window. For the same reason you can't debug the requests in network tab of developer tools. However Mirage could be configured to log intercepted requests to console.