1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

Enable ability to mock endpoints in development mode

no issue
- moves existing mirage config into the `testConfig()` function to retain full mocks during testing
- configure mirage to passthrough all requests when in development mode
This commit is contained in:
Kevin Ansfield 2016-04-13 10:44:09 +01:00
parent 084df31ca1
commit f105d077bb
2 changed files with 17 additions and 7 deletions

View file

@ -52,6 +52,22 @@ export default function () {
this.namespace = 'ghost/api/v0.1'; // make this `api`, for example, if your API is namespaced
// this.timing = 400; // delay for each request, automatically set to 0 during testing
// Mock endpoints here to override real API requests during development
// keep this line, it allows all other API requests to hit the real server
this.passthrough();
// add any external domains to make sure those get passed through too
this.passthrough('https://count.ghost.org/');
this.passthrough('http://www.gravatar.com/**');
}
// Mock all endpoints here as there is no real API during testing
export function testConfig() {
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
this.namespace = 'ghost/api/v0.1'; // make this `api`, for example, if your API is namespaced
// this.timing = 400; // delay for each request, automatically set to 0 during testing
/* Authentication ------------------------------------------------------- */
this.post('/authentication/token', function () {
@ -326,10 +342,3 @@ export default function () {
};
});
}
/*
You can optionally export a config that is only loaded during tests
export function testConfig() {
}
*/

View file

@ -32,6 +32,7 @@ module.exports = function (environment) {
ENV.APP.LOG_TRANSITIONS = true;
ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
ENV.APP.LOG_VIEW_LOOKUPS = true;
// Enable mirage here in order to mock API endpoints during development
ENV['ember-cli-mirage'] = {
enabled: false
};