[英]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.我正在尝试在 Mocha 中进行一个简单的测试,以验证除法的结果是否返回一个数字,但该测试始终未决。
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.顺便说一下,我建议使用
assert.StrictEqual()
因为assert.equal()
已被弃用。
So the working code:所以工作代码:
describe("Return result", () => {
it("return a nb when string.lgth / number", () => {
const text = "oula";
assert.strictEqual((text.length/2),2)
})
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.