zombie : ajax 呼叫无效

zombie : ajax call don't work

我正在使用 behat/mink 和 zombie.js 进行测试。 到目前为止一切正常,直到我想测试一个 ajax 调用。 我正在使用 API (fixer.io) 来兑换货币。这部分效果很好:用户选择原始货币、项目数量、设置价格和金额自动转换为欧元。

在我的 js 测试 僵尸中,我填写了每个字段,用户应该看到原始货币的金额 + 转换为欧元的金额。但是转换后的金额没有显示在页面上:ajax 调用总是 return 错误。 然后我看到了这个问题 https://github.com/assaf/zombie/issues/417 .

绝对没有办法测试与僵尸的xhr同步?

已通过此答案的 Use Promises 部分解决 How do I return the response from an asynchronous call? 然后告诉 behat 等待我的 ajax 回调。

/**
* @Given I wait
*/
public function iWait()
{
    $this->getSession()->wait(5000);
}