【问题标题】:Run a simple test in Mocha在 Mocha 中运行一个简单的测试
【发布时间】:2020-10-16 09:02:30
【问题描述】:

我正在尝试在 Mocha 中进行一个简单的测试,以验证除法的结果是否返回一个数字,但测试始终处于未决状态。

describe("Return result", () => {
   it("return a nb when string.lgth / number"), () => {
    const text = "oula";
    assert.equal((text.length/2),2)
   }

})

我做错了什么?

【问题讨论】:

    标签: javascript reactjs mocha.js


    【解决方案1】:

    是一个最小的错误,但仍然是一个错误。

    定义写的不好,应该是

    it("...", () => {

    但你有:

    it("..."), () => {

    几乎一样,只是挂了执行。

    顺便说一句,我建议使用assert.StrictEqual(),因为assert.equal() 已被弃用。

    所以工作代码:

    describe("Return result", () => {
        it("return a nb when string.lgth / number", () => {
            const text = "oula";
            assert.strictEqual((text.length/2),2)
        })
    })
    

    【讨论】:

      猜你喜欢
      • 2018-12-02
      • 1970-01-01
      • 2012-06-05
      • 1970-01-01
      • 2016-06-28
      • 2023-04-05
      • 1970-01-01
      • 2020-08-26
      • 2015-11-29
      相关资源
      最近更新 更多