acquia / ember-logging-service

A generic ember logging service
MIT License
3 stars 0 forks source link

Unit testing controller wants logging service #4

Open jrock2004 opened 7 years ago

jrock2004 commented 7 years ago

So I am using your plugin and when I am writing a unit test for my controller, its erroring in the test because its expecting the logging service. Here is what I have in my environment.js file

Attempting to inject an unknown injection: 'service:logger'

if (environment === 'test') {
    // Testem prefers this...
    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';

    ENV['ember-logging-service'] = {
      enabled: false,
      errorsEnabled: false
    };
  }

Thoughts?

chuckcarpenter commented 6 years ago

@jrock2004 if your controller is injecting the service, you'll need needs: ['service:logger'] in the unit test. Also, no way to turn it off in the test unless you're going to have some sort of mock helper.