WebStorm Mocha:测试始终未决

WebStorm Mocha : tests are always pending

我观看了有关如何在 WebStorm 中设置 Mocha 的 WebStorm 视频:

https://www.youtube.com/watch?time_continue=81&v=4mKiGkokyx8

我创建了一个非常简单的测试,有一个通过和一个失败:

var assert = require("assert")
describe('Array', function() {
  describe('#indexOf()', function() {

    it('should return -'), function() {
      assert.equal(-1, [1,2,3].indexOf(5))
    }


    it('should fail'), function() {
      assert.equal(1, [1,2,3].indexOf(5))
    }
  })
})

然后我设置一个 运行 配置如下:

然后我运行它。它只是说明测试是 'pending',然后过程完成:

为什么会这样?

你的两个测试都被忽略了,因为你使用了不正确的 it() 语法。请尝试按如下方式更改套件:

var assert = require("assert")
describe('Array', function() {
    describe('#indexOf()', function() {

        it('should return -', function() {
            assert.equal(-1, [1,2,3].indexOf(5))
        })


        it('should fail', function() {
            assert.equal(1, [1,2,3].indexOf(5))
        })
    })
})