【问题标题】:JSHint warns that Mocha 'beforeEach' is not defined even when using "mocha": trueJSHint 警告说,即使使用“mocha”,也没有定义 Mocha 'beforeEach':true
【发布时间】:2015-10-07 03:44:43
【问题描述】:

我将 Ember-cli 与 Mocha 一起使用,我的测试导致 JSHint 测试失败(测试实际上通过了)。

'beforeEach' 没有定义。

我尝试将"mocha": true 选项添加到我的.jshintrc 中,正如the docs 中所说的那样。 我还尝试将其添加到"globals": { "beforeEach": true }

我正在使用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');
    });
  }
);

【问题讨论】:

  • 添加 `import { beforeEach } from 'mocha';` 使警告静音,但为什么 JSHint 没有选择配置。

标签: javascript ember.js mocha.js ember-cli jshint


【解决方案1】:

显然你需要关闭 ember cli 测试服务器并重新启动它。

【讨论】:

    猜你喜欢
    • 2019-03-04
    • 2014-06-09
    • 2015-12-16
    • 1970-01-01
    • 2017-10-02
    • 2013-04-22
    • 2018-06-13
    • 1970-01-01
    相关资源
    最近更新 更多