question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Server is undefined while in test environment

See original GitHub issue

First and foremost, thanks for writing up this addon! It is such a great addition to the community.

Problem When running tests at http://localhost:4200/tests I’m getting ReferenceError: server is not defined. Not sure exactly how this might be happening since I’ve enabled ember-cli-mirage for testing mode only.

Note: This error does not occur when running ember test

config/environment.js

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'cio',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {}
    },

    APP: {}
  };

  ENV.APP.FORCE_REST_ADAPTER = false
  ENV.APP.PROFILE_RENDERS = false
  // Disable ember-cli-mirage by default, we want to use our local api for development
  ENV['ember-cli-mirage'] = {
    enabled: false
  };

  if (environment === 'development') {}

  if (environment === 'production') {}

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

    // Root Element
    ENV.APP.rootElement = '#ember-testing';

    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  return ENV;
};

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:24 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
samselikoffcommented, Apr 6, 2015

I do see the logic in index.js is wrong, I need to include Mirage during development build even if enabled: false is specified, precisely for this reason.

To get around this for now, remove the enabled: false option from your default config, and either use ember test --server, or add a blank file under /server/proxies or pass the --proxy option. (You can remove the enabled: true line as well, it’s enabled by default).

0reactions
albertpakcommented, Dec 12, 2016

My app is on ember 2.5.3 - i did add server to .jshintrc in home folder and then in tests folder also, in predef section

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server is undefined while in test environment #81 - GitHub
Problem When running tests at http://localhost:4200/tests I'm getting ReferenceError: ... Server is undefined while in test environment #81.
Read more >
next.js environment variables are undefined (Next.js 10.0.5)
But in my console I get a "test undefined". I tried to put my variable into an .env file instead, without success. What...
Read more >
Why does testing datasources from admin console fail ... - IBM
BPM deployment environment creation use "WAS_INSTALL_ROOT" variable while defining the data source at a cell level and cluster level.
Read more >
Testing with Node, Jest, and JSDOM - Manning Publications
In this article, you'll learn how to use Node and Jest to test code written ... By using passing the value "jsdom" to...
Read more >
Environment Variables in Next.js - Frontend Digest
The environment variable is not yet defined on the client, so undefined gets logged instead. You'll notice that the browser will log undefined...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found