简体   繁体   English

.done()在我的摩卡测试中出了什么问题?

[英]What is wrong in my mocha test with .done()?

In my mocha test I have something like this 在我的摩卡咖啡测试中,我有这样的东西

it.only("diag", function(done) {
        let data = null;
        app.client.timeoutsAsyncScript(5000).executeAsync(function(data, done) {
            console.log("START");
            done();
        });
    });

In my application I can see that console.log has been done. 在我的应用程序中,我可以看到console.log已经完成。 But this function .done() was never called. 但是从未调用过此函数.done()。 Why ? 为什么呢 What could be wrong ? 有什么问题吗?

Thanks for the help! 谢谢您的帮助!

You have parameter with the same name "done" in your callback function. 您的回调函数中具有相同名称的参数“ done” The variable from the local scope is used over the variable from outer scope. 来自本地作用域的变量被用于来自外部作用域的变量。 You can either remove it or rename it eg executeAsync(function(data, done2) { ... 您可以将其删除或重命名,例如executeAsync(function(data, done2) { ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 这个异步JavaScript函数的单元测试(通过Mocha / Sinon)有什么问题? - What's wrong with this unit test of an async JavaScript function (via Mocha/Sinon)? 我的firefox浏览器测试出了什么问题? - What is wrong with my firefox browser test? 摩卡,nodejs承诺测试会因为缺少完成而无法完成 - Mocha, nodejs promise test can't finish because lack of done 如何使用async-await,然后在一次Mocha测试中完成? - How to use async-await and then in one Mocha test with done? 猫鼬mongodb保存子文件混乱吗? 摩卡测试未完成() - Mongoose mongodb saving sub documents confusion? Mocha test not getting to done() 确保在此测试中调用done()回调(Mocha,Chai,Sinon) - Ensure the done() callback is being called in this test (Mocha, Chai, Sinon) 测试失败 - 多次调用 Mocha 的 done() - Failing test - Mocha's done() called multiple times 在 mocha 测试中使用 done 和 setTimeout 的简单示例未按预期工作 - Simple example using done and setTimeout inside a mocha test not working as expected 为什么在报告程序处理完测试失败之前,Mocha会退出? - Why does Mocha exit before a reporter is done handling a test failure? 摩卡咖啡在测试中未调用我的函数 - Mocha not calling my function in my test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM