Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 1018 Bytes

no-ember-testing-in-module-scope.md

File metadata and controls

53 lines (42 loc) · 1018 Bytes

Ember.testing is not allowed in modules scope

Rule name: no-ember-testing-in-module-scope

Since [email protected] / [email protected], Ember.testing is only set to true while a test is executing instead of all the time. Also, Ember.testing is a getter/setter in Ember and destructuring will only read its value at the time of destructuring. emberjs/ember-test-helpers#227

// Good
export default Component.extend({
  someMethod() {
    if (Ember.testing) {
      doSomething();
    } else {
      doSomethingElse();
    }
  }
})

// Good
export default Service.extend({
  foo() {
    _bar(Ember.testing ? 0 : 400)
  }
})

// Bad
export default Component.extend({
  init() {
    this.isTesting = Ember.testing
  }
})

// Bad
import Ember from 'ember';

export default Ember.Component.extend({
  isTesting: Ember.testing
})

// Bad
import Ember from 'ember';

const IS_TESTING = Ember.testing;

// Bad
import Ember from 'ember';

const { testing } = Ember;