# Turn off ember-cli-mirage

**URL:** <https://discuss.emberjs.com/t/turn-off-ember-cli-mirage/13903>\
**Category:** Uncategorized\
**Created:** [November 21, 2017, 10:25am UTC](https://discuss.emberjs.com/t/turn-off-ember-cli-mirage/13903 "2017-11-21T10:25:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GELight](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gelight/32/12902_2.png) [@GELight](https://discuss.emberjs.com/u/GELight)\
**Post date:** [November 21, 2017, 10:25am UTC](https://discuss.emberjs.com/t/turn-off-ember-cli-mirage/13903/1 "2017-11-21T10:25:44Z")

</div>

Hi all,

It’s possible to use **ember mirage** only for tests? Currently I set another namespace variable in test environment.

```
http://localhost:4202/tokens >>> Called in the running application
http://localhost:4202/test/tokens >>> Namespace "/test" is set for test environment only

```

After installing ember-cli-mirage **ALL** requests are redirected by **ember mirage**. For our application we have real requests to a gateway. We only need **ember mirage** for testing. Is this possible?

Best regards, Mario

---

<div class="post-metadata">

**Author:** ![Henry](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/henry/32/16850_2.png) [@Henry](https://discuss.emberjs.com/u/Henry)\
**Post date:** [November 21, 2017, 10:35am UTC](https://discuss.emberjs.com/t/turn-off-ember-cli-mirage/13903/2 "2017-11-21T10:35:05Z")

</div>

Check the official documentation [link](http://www.ember-cli-mirage.com/docs/v0.3.x/configuration/#environment-options)

Basically you can specify in the `environment.js` when do you want `ember-cli-mirage` to be enabled:

example:

```auto
if (environment === 'production') {
  ENV['ember-cli-mirage'] = {
    enabled: true
  };
}

```

---

<div class="post-metadata">

**Author:** ![GELight](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gelight/32/12902_2.png) [@GELight](https://discuss.emberjs.com/u/GELight)\
**Post date:** [November 21, 2017, 11:59am UTC](https://discuss.emberjs.com/t/turn-off-ember-cli-mirage/13903/3 "2017-11-21T11:59:52Z")

</div>

Ah… very thanks to you. In the same moment I found this documentation too. 🙂

Greetings Mario

---

<div class="post-metadata">

**Author:** ![GELight](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gelight/32/12902_2.png) [@GELight](https://discuss.emberjs.com/u/GELight)\
**Post date:** [November 21, 2017, 12:31pm UTC](https://discuss.emberjs.com/t/turn-off-ember-cli-mirage/13903/4 "2017-11-21T12:31:57Z")

</div>

Ok… still not all fine. 🙂

In my environment “development” ( in my Application ) the defined mirage rules will used correctly. But in my acceptance test mirage writes an error:

```
'Mirage: Your Ember app tried to POST \'http://localhost:4202/tokens\',\n but there was no route defined to handle this request.\n Define a route the at matches this path in your\n mirage/config.js file. Did you forget to add your namespace?' { description: 'Mirage: undefined', message: 'Mirage: Your Ember app tried to POST 'http://localhost:4202/tokens\',\n but there was no route defined to handle this request.\n Define a route that matches this path in your\n mirage/config.js file. Did you forget to add your namespace?', name: 'Error', stack: 'Mirage: Error: Your Ember app tried to POST \'http://localhost:4202/tokens\',\n but there was no route defined to handle this request.\n D efine a route that matches this path in your\n mirage/config.js file. Did you forget to add your namespace?\n at new MirageError (http://localhost:4203/a ssets/vendor.js:132407:21)\n at assert http://localhost:4203/assets/vendor.js:132394:13)\n at Pretender.unhandledRequest (http://localhost:4203/assets/vendor [Press ENTER to run tests; q to quit; p to pause]

```

Currently in both use cases I used no different namespace. ( both the same ) In the app all is fine. In the test mirage do not find my defined mirage routes.

Any ideas?

**[EDIT]** In my acceptance test there is this route definition set on first line:

```
server.post('/tokens', () => {
    return new Mirage.Response(200, {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'authentication-token': generateToken()
    }, {});
});

```

Greetings Mario

---

<div class="post-metadata">

**Author:** ![Henry](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/henry/32/16850_2.png) [@Henry](https://discuss.emberjs.com/u/Henry)\
**Post date:** [November 22, 2017, 2:23pm UTC](https://discuss.emberjs.com/t/turn-off-ember-cli-mirage/13903/5 "2017-11-22T14:23:34Z")

</div>

Are you sure that’s the only test that access to that route? In the documentation says that the handler `server.post` only works for that specific test:

> This route handler definition is only in effect for the duration of this test, so as soon as it’s over any handler you have defined for POST to /questions in your config.js file will be used again.

---

<div class="post-metadata">

**Author:** ![GELight](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gelight/32/12902_2.png) [@GELight](https://discuss.emberjs.com/u/GELight)\
**Post date:** [November 22, 2017, 11:12pm UTC](https://discuss.emberjs.com/t/turn-off-ember-cli-mirage/13903/6 "2017-11-22T23:12:44Z")

</div>

Problem solved. The problem was the host. Mirge do not tells me in the log whether the host is set relative or absolute.

After setting the host in the mirage/config.js, the test could use the defined route too. My test route definition in my test was removed before…

🙂
