【发布时间】:2019-05-29 05:18:40
【问题描述】:
我正在使用WebdriverIO 运行我的功能测试。即使没有async/await,我也可以通过 WebdriverIO 测试。但我读过一些文章,async/await 是编写 javascript 来处理 Promise 的最佳方式。
我是 Javascript 新手,对 Promise 很迷茫。在 WebdriverIO 中编写代码的最佳方式是什么(是否使用异步/等待 | 例如:在配置中关闭同步并使用它?)
wdio.conf.js 配置文件声明如下:
// By default WebdriverIO commands are executed in a synchronous way using
// the wdio-sync package. If you still want to run your tests in an async
// e.g. using promises you can set the sync option to false.
//
sync: true
【问题讨论】:
-
请在问题中添加您的代码
-
我重新表述了我的问题。我想弄清楚
is using async/await in webdriverio the best way of coding by turning sync off in configuration file or not using it by turning sync on in that file -
不要相信你读过的每一篇文章。如果您来自传统的顺序编程环境,请继续使用
sync: true。否则,如果你想在 JS 和使用 Promises 方面表现出色,那就去sync: false。这只是味道...... w/e 漂浮在你的船。