# Ember: mock rest spi call using mockjax

**URL:** <https://discuss.emberjs.com/t/ember-mock-rest-spi-call-using-mockjax/6021>\
**Category:** Testing\
**Created:** [August 4, 2014, 1:20pm UTC](https://discuss.emberjs.com/t/ember-mock-rest-spi-call-using-mockjax/6021 "2014-08-04T13:20:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![swatijadhav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/swatijadhav/32/15964_2.png) [@swatijadhav](https://discuss.emberjs.com/u/swatijadhav)\
**Post date:** [August 4, 2014, 1:20pm UTC](https://discuss.emberjs.com/t/ember-mock-rest-spi-call-using-mockjax/6021/1 "2014-08-04T13:20:06Z")

</div>

I am using ember-cli to develop ember application and ember-data with restful api calls to rails backend.

Also using qunit for testing purpose. ([https://github.com/appendto/jquery-mockjax](https://github.com/appendto/jquery-mockjax) for mocking ajax request)

Here am facing issue while mocking the ajax requests

```
import Ember from "ember";
import DS from "ember-data";
import { test, moduleFor } from 'ember-qunit';
import startApp from '../../helpers/start-app';
var App;

module('Integration Test', {
  setup: function() {
    App = startApp();
    Ember.$.mockjax({
      url: '/api/v1/offers',
      type: 'GET',
      responseText: {
        offers: [{
          id: 1,
          state: 'draft'
        }]
      }
    });
  },

  teardown: function() {
    Ember.run(App, App.destroy);
  }
});

test('small test', function () {
  console.log("in")
  $.get('/api/v1/offers')
  console.log($.mockjax.mockedAjaxCalls().length);
  console.log("start")

  visit('/offers/1').then(function(){
    equal($('p.item_count').text(), "Offer Items(0)");
  });
  console.log($.mockjax.mockedAjaxCalls().length);
});

```

On console it produces output as

```
in
MOCK GET: /api/v1/offers 
Object {url: "/api/v1/offers", type: "get", isLocal: false, global: true, processData: true…}
start
1 
1 

```

here the api is called using restful adapter, but not using the mocked ajax call.

Can anyone pls help to fix this issue.

Thanks.
