title: Ember CLI with http-mock and pretender, how to manage mock data
body: <p>I'm new to Javascript in general, especially EmberJS and Ember CLI. I'm trying to figure out what is the best practice to manage mock data within a Ember CLI based project. I'm on 0.1.14 EmberCLI now.</p>
  
  <p>According to Ember CLI documentation, http-mock is the preferred way of providing mock data for Ember Data models. So I use generated http-mock and added some test data to it.</p>
  
  <pre><code>  var testData = [
    ...
  
    ];
  
    module.exports = function(app) {
      var express = require('express');
      var todosRouter = express.Router();
  
      todosRouter.get('/', function(req, res) {
        res.send({
          "todos": testData
        });
      });
  </code></pre>
  
  <p>Then I found out that the http-mock does not work during integration, so I added Pretende.</p>
  
  <pre><code>  import Ember from 'ember';
    import { test } from 'ember-qunit';
    import Pretender from 'pretender';
    import startApp from '../helpers/start-app';
  
    var App;
    var server;
  
    var testData = [
      ...
      ];
  
    module('An Integration test', {
      setup: function() {
        App = startApp();
        server = new Pretender(function(){
          this.get('/api/todos', function(request){
             return [ 200, {"Content-Type": "application/json"},
                      JSON.stringify({'todos': testData) ];
          });
        });
      },
      teardown: function() {
        ...
      }
    });
  
  
    test('3 items loaded at startup', function() {
    ...
    });
  </code></pre>
  
  <p>Both http-mock and integration test work fine, then I tried put the test data in a separate module so that they can be shared. The thing is that the integration test uses ES6 style module import, and http-mock uses CommonJS style module definition, and I don't know how to combine them into the project.</p>
  
  <p>If I construct the data into an ES6 module, </p>
  
  <pre><code>var mockData = [
  ...
  ];
  
  
  export default {
    all: mockData
  };
  </code></pre>
  
  <p>it works with integration test but http-mock complains about unexpected reserved word "export". If a convert it to a CommonJS style module.export, then I can't see the data in the integration test. </p>
  
  <p>Now the questions:</p>
  
  <ol>
  <li>I think if Broccoli 'compile' ES6 module into CommonJS format it should work with http-mock, but I have no idea how to do that. Is this the right direction to go, and how?</li>
  <li>Do I have to use both http-mock and Pretender in the same project? Can I use one for both development and integration test?</li>
  </ol>
  
  <p>I'm stuck here and comments, suggestions and code samples are really appreciated. </p>