JavaScript标准样式不能识别摩卡

我有一个Mocha测试文件,如下所示:

var expect = require('chai').expect
var muting = require('../muting')

describe('muting', function () {
  describe('init()', function () {
    it('should inject an object into twitter', function () {
      var twitter = 'twitter'
      muting.init(twitter)
      expect(muting.twitter).to.equal(twitter)
    })
  })
})

当我从CLI运行摩卡时,它会成功运行测试。

当我运行标准(JavaScript Standard Style的可执行文件)时,我得到了摩卡框架功能的错误:

standard: Use JavaScript Standard Style (https://github.com/feross/standard)   
c:\..\test\index.js:5:0: 'describe' is not defined.  
c:\..\test\index.js:6:2: 'describe' is not defined.  
c:\..\test\index.js:7:4: 'it' is not defined.

标准不干净这些功能最干净的方法是什么?

您可以使用与web workers相同的解决方案

/* global describe it */
var expect = require('chai').expect
var muting = require('../muting')

describe('muting', function () {
  describe('init()', function () {
    it('should inject an object into twitter', function () {
     var twitter = 'twitter'
     muting.init(twitter)
     expect(muting.twitter).to.equal(twitter)
    })
  })
})
http://stackoverflow.com/questions/30018271/javascript-standard-style-does-not-recognize-mocha

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:JavaScript标准样式不能识别摩卡