Mirage

Mirage Guide

ember install ember-cli-mirage

config/environment.js

if (environment === 'development') {
  ENV['ember-cli-mirage'] = {
    enabled: false,
  };
}

.eslintignore

/mirage/mirage

Acceptance tests

import { setupMirage } from 'ember-cli-mirage/test-support';

module('Acceptance | Homepage test', function(hooks) {
  setupApplicationTest(hooks);
  setupMirage(hooks);

Auth

this.post('/oauth/token', () => {
  return {
    access_token: 'fake_access_token',
    token_type: 'bearer',
    expires_in: 7200,
    created_at: 1531855327,
  };
});
this.get('/todos', (schema, request) => {
  const searchText = request.queryParams['filter[search]'];
  if (searchText) {
    return schema.todos.where(todo =>
        includesCaseInsensitive(todo.name, searchText),
    );
  } else {
    return schema.todos.all();
  }
});