Functional testing Laravel ajax control

In laravel 5.4, I see that there are methods like:

$browser->pause(1000); $browser->waitFor('.selector'); $browser->waitForLink('Create'); 

But I do not see them in Laravel 5.3.

We have two chained selection blocks into which the values ​​of the second selection window are loaded via ajax based on the selection from the first selection block. The problem is that when the laravel test starts, the second selectbox / ajax does not wait to load, which leads to a test failure, because it cannot select any value from the second selection block.

 $this->visit('/department'); $this->select('1', 'country_id'); $this->select('1', 'region_id'); // problem here // rest of code 

I also tried using sleep() , but that did not work.

Any idea on functional testing of such a scenario in 5.3, please? Thanks

+8
php laravel
source share
2 answers

By default, laravel 5.3 does not support this feature. Because they introduced Ajax Testing in laravel 5.4 using Dusk.

Check this post: https://laravel-news.com/laravel-dusk-is-coming

However, we were lucky.

Looking at composer .json twilight. You can use it in laravel 5.3, since its dependency is "illuminate/support" : "~5.3" , which satisfies Laravel 5.3.

All you have to do is: composer require laravel/dusk

Check out composer.json here: https://github.com/laravel/dusk/blob/master/composer.json

Edit:

There was a problem with addiction. I created a new package that resolved the dependency problem. I checked all the test cases. This did not give me any errors.

You can use this package using the following command: composer require pankitgami/dusk

Check here: https://packagist.org/packages/pankitgami/dusk

+8
source share

seeJsonEquals used to check for exact JSON match

  $this->post('/user', ['name' => 'Sally']) ->seeJsonEquals([ 'created' => true, ]); 
+1
source share

All Articles