ember-cli-mirage: 'server' is not defined

I writing an acceptance test and got an error:

acceptance/redirect-test.js: line 7, col 3, ‘server’ is not defined.

acceptance/redirect-test.js file

import { test } from 'qunit';
import moduleForAcceptance from 'websizy-dashboard/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | redirect');

test('should redirect to website index', function(assert) {
  server.createList('website', 1);

  visit('/websites');

  andThen(function() {
    assert.equal(currentRouteName(), 'website.index');
  });
});

Ember: 2.9.1 ember-cli: 2.9.1 ember-cli-mirage: 0.2.4 node: 6.8.0 phantomjs: 2.1.1

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 23 (5 by maintainers)

Most upvoted comments

I’m also having this issue, on Ember 2.10.0. I’m using eslint however.

tests/.eslintrc.js

module.exports = {
  root: true,
  extends: '../.eslintrc.js',
  globals: {
    'server': true
  },
  env: {
    'embertest': true,
    'es6': true
  }
};

Figured it out - i had a system wide setting for the environment to be set to development mode, so the app never went into test environment 👊

Lesson learned - pay attention even closer! lol

So take away is to enable the server - make sure you set the settings correctly in your config/environment file and enable mirage in your proper environment.

Hopefully this will somehow help someone else 😃

Ran into this issue this week - generated an acceptance test, tried to use server.create('user') and got an error that server is not defined, checked .jshintrc and "server" is in it