Search code examples
javascriptember.jsmocha.jsember-clijshint

JSHint warns that Mocha 'beforeEach' is not defined even when using "mocha": true


I'm using the Ember-cli with Mocha and my test is causing the JSHint test to fail (the test is actually passing).

'beforeEach' is not defined.

I tried adding the "mocha": true option to my .jshintrc as it says in the docs. I also tried adding it to "globals": { "beforeEach": true }.

I'm running the tests with ember test --server.

/* jshint expr:true */
import { expect } from 'chai';
import {
  describeModel,
  it
} from 'ember-mocha';

describeModel(
  'user',
  'User',
  {
    // Specify the other units that are required for this test.
      needs: []
  },
  function() {

    beforeEach(function(){
      this.model = this.subject({
        email: 'test@example.com'
      });
    });

    // Replace this with your real tests.
    it('exists', function() {
      // var store = this.store();
      expect(this.model.get('email')).to.equal('test@example.com');
    });
  }
);

Solution

  • Apparently you need to close the ember cli test server and start it again.