简体   繁体   English

僵尸:ajax调用不起作用

[英]zombie : ajax call don't work

I'm using behat/mink with zombie.js for testing. 我正在使用behat / mink和zombie.js进行测试。 Everything workedwell so far, until I wanted to test an ajax call. 到目前为止,一切工作正常,直到我想测试一个ajax调用。 I'm using an API (fixer.io) to convert money. 我正在使用API​​(fixer.io)进行货币兑换。 This part works well : the user choose the original currency, number of items, set the price and the amount is automatically converted into euro. 这部分效果很好:用户选择原始货币,项目数量,设置价格和金额会自动转换为欧元。

In my js test with zombie, I fill every fields and the user should see the amount in original currency + converted in euro. 在僵尸的js测试中 ,我填写了每个字段,用户应该看到原始货币的金额+转换为欧元的金额。 But the converted amount doesn't show on the page : the ajax call always return error. 但是转换后的金额不会显示在页面上:ajax调用总是返回错误。 then I saw this issue https://github.com/assaf/zombie/issues/417 . 然后我看到了这个问题https://github.com/assaf/zombie/issues/417

There is absolutely no way to test xhr sync with zombie ? 绝对没有办法用僵尸测试xhr同步吗?

Resolved with the Use Promises part of this answer How do I return the response from an asynchronous call? 已通过此答案的“ 使用承诺”部分解决。 如何从异步调用返回响应? And the by telling to behat to wait for my ajax callback. 然后通过告诉behat等待我的Ajax回调。

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

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM