简体   繁体   中英

Run a simple test in Mocha

I'm trying to do a simple test in Mocha to verify that the result of a division return a number but the test is always pending.

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

})

What did i do wrong?

Is a minimal error but still an error.

The definition is bad written, should be

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

But you have:

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

Is almost the same, but hang the execution.

By the way, I recommend use assert.StrictEqual() because assert.equal() is deprecated.

So the working code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM