Unit testing Chai测试框架未给出通过单元测试的消息

Unit testing Chai测试框架未给出通过单元测试的消息,unit-testing,mocha.js,chai,Unit Testing,Mocha.js,Chai,这是我的密码: const chai = require('chai') describe('add',function(){ chai.should() const result = 6 result.should.be.a('number') result.should.equal(6) }) 当我运行节点测试时,我得到以下结果: > mocha 0 passing (5ms) package.json: { "name": "test

这是我的密码:

const chai = require('chai')

describe('add',function(){

   chai.should()
   const result = 6

   result.should.be.a('number')
   result.should.equal(6)

})
当我运行节点测试时,我得到以下结果:

> mocha



  0 passing (5ms)
package.json:

{
  "name": "test-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "chai": "^4.0.2",
    "mocha": "^3.4.2"
  },
  "devDependencies": {
    "chai":"*",
    "mocha":"*"
  }
}

告诉Mocha您有一个测试的方法是将您的测试作为对Mocha提供的
it
函数的回调<代码>描述对测试进行分组,但不定义任何测试。因此,如果您有一个
描述
而没有
,那么您就没有测试


Chai对摩卡的运营方式没有影响。摩卡咖啡不在乎柴在那里,也不在乎你在用它。当断言失败时,您可以将Mocha与任何引发异常或拒绝承诺(并从测试中返回承诺)的断言库一起使用。柴就是这样一个图书馆。您可以将Chai与Mocha之外的另一个测试运行程序一起使用。

如果您在其中放入一个实际的规范(
it('…',function(){…})
),那会怎么样?但Chai的全部目的不是要替换it函数。我认为Chai只是一个断言库,您仍然需要测试运行程序;这就是为什么你也有摩卡咖啡。