这里是 Javascript/Cypress 的相对新手。我正在使用 Cypress Cucumber.js 插件运行一些测试。问题是我无法让我的步骤按顺序运行 - 由于 js 的异步性质,“Then”步骤在“Given”等之前运行。显然,这会成为一个问题,因为测试会失败!
我的问题:
1)我们如何使用异步代码使黄瓜步骤始终按顺序运行?我在这里看到了类似的问题:How to wait for a JavaScript Promise to resolve before resuming function? ,并根据我对给定块应用 async/await 的响应,希望它会在我的步骤中强制执行命令,但这不起作用。
这是我的功能文件:
Given I get the data from CMS
Then I can verify that the title is the same as the CMA title in tab "0"
And I can verify that the link is the correct link in tab "0"
Run Code Online (Sandbox Code Playgroud)
脚步:
Given('I get the data from CMS', async() => {
let api = await …Run Code Online (Sandbox Code Playgroud)