Laravel 单元测试延迟

Laravel unit test delay

是否可以在 L5 单元测试中等待。我有以下案例

$this->visit('/')
    ->select('Customer A', 'customer')// This will fire $.getJSON and populate the 'project' select object
    //I need to wait a bit here for the 'project' select object to be populated
    ->select('Project A', 'project')

名为 customer 的 select 对象在更改时触发 $.getJSON,它填充 project select 对象。

这将不起作用,因为 Ajax 请求是在页面加载后触发的。并且它不包含来自 Ajax 请求的项目数据。

您可以查看 laracasts/integrated from here and use Selenium driver if you want to use waitForElement()

然后您可以等待指定的时间段等待ajax个请求完成。