Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Testing Vue components with Laravel Dusk
Mar 14, 2018 @ 18:09:52

On the Laravel News site there's a new post showing how you can test Vue.js applications with Laravel Dusk, a testing tool created by the Laravel project to make it easier to create integration tests that are run with a ChromeDriver.

Adding tests to a project is always beneficial for different aspects, but choosing the right strategy could be a struggle for many developers.

The problem multiplies itself when you are using different tools or frameworks, and although “having as many tests as you can” sounds like a good idea, at least in theory, in practice this can be very different. The following is an interesting article from the Twitter team about their thoughts on Feature Testing.

Taylor Otwell shared Twitter’s article on his Bi-Weekly Laravel Tips newsletter, subscribe if you haven’t done yet. Let’s build a simple to-do list using Vue.js and Laravel to illustrate how to add Browser testing using Laravel dusk.

They starts with the controller code to create "tasks" functionality for read/write/update/delete that includes request validation, model binding and JSON responses. It then includes the code to create the first "task" tests for each of the CRUD operations. With those basics in place, the tutorial then gets into the Vue.js side, showing how to test a simple TasksComponent.vue file and its functionality.

tagged: laravel dusk testing crud task vuejs tutorial

Link: https://laravel-news.com/testing-vue-components-with-laravel-dusk

SitePoint PHP Blog:
Laravel Dusk – Intuitive and Easy Browser Testing for All!
Feb 23, 2017 @ 18:54:06

On the SitePoint PHP blog there's a tutorial posted that introduces you to Laravel Dusk, a browser-based testing tool, and how it can be used to test a Laravel-based application.

End to end testing for JavaScript applications, particularly single-page-apps, has always been a challenge. To that end, Laravel released its 5.4 version recently with a new testing library: Dusk.

With the release of Dusk, Laravel hopes to give its users a common API for browser testing. It ships with the default ChromeDriver, and if we need support for other browsers, we can use Selenium. It will still have this common testing API to cater to our needs.

The tutorial then walks you through the installation process and two approaches to getting it integrated into your application. They then create a first test, checking to see if a user can log in successfully. They also include how it looks when a test fails and the screenshot that's taken just before the failure. It also covers the testing of Ajax-related calls, inserting a delay when a button is clicked to wait for the response. Finally, the tutorial shows a more advanced example involving a popup modal, a form and multiple interactions.

tagged: laravel dusk browser testing tutorial introduction ajax example

Link: https://www.sitepoint.com/laravel-dusk-intuitive-and-easy-browser-testing-for-all/

Matt Stauffer:
Introducing Laravel Dusk (new in Laravel 5.4)
Feb 06, 2017 @ 15:46:06

Kicking off his series of posts looking at the new features that come along with the v5.4 release of the Laravel Framework Matt Stauffer has posted a look at Dusk, a tool that makes it simpler to test your Laravel based applications.

If you follow anyone in the Laravel world on Twitter, or if you listen to the Laravel Podcast, you know by now that Laravel Dusk is the new face of application testing in the Laravel world.

[...] With Dusk, Taylor has completely re-written how application testing works in Laravel. Everything is now based on a tool called ChromeDriver, which is a standalone server that actually controls Chrome/Chromium. When you write application tests, Dusk sends your commands to ChromeDriver, which then spins up Chrome to run your tests in the browser and then reports back the results.

He starts with a brief look at how testing was being performed in most cases on Laravel applications (using the "Integrated" package) but pointed out that that only really worked for non-Javascript driven sites. With the introduction of Dusk and it's use of the ChromeDriver to make "browsing" in the test simpler. He includes the installation process of the latest version of Dusk and an example test checking to be sure the string "Laravel" is in a page. He includes a gif of the test in action and talks about some of the new interactions and assertions included in the tool. He wraps up the post looking at the use of Pages and a few other miscellaneous tips to help you get your testing up and working productively.

tagged: laravel framework testing dusk introduction tutorial interactions pages

Link: https://mattstauffer.co/blog/introducing-laravel-dusk-new-in-laravel-5-4

Laravel News:
Laravel Dusk Is Coming to Laravel 5.4
Dec 28, 2016 @ 15:53:48

On the Laravel News site there's an announcement posted about a new tool coming to the Laravel ecosystem - Laravel Dusk. Dusk is a browser testing tool that makes it easier to test Laravel-based Javascript-heavy applications.

When you write end-to-end tests, Laravel provides a set of useful helper methods which make it easy to click a link, fill an input field, or submit a form. Under the hood, Laravel uses the Symfony BrowserKit component to simulate the behavior of the web browser. However, if your app uses JavaScript and AJAX to load the page, BrowserKit will not work for you.

Laravel Dusk is a new tool that will be introduced in Laravel 5.4 to solve this problem.

The post goes on to talk about the tool and what kind of functionality powers it - a combination of ChromeDriver and the Facebook PHP-Webdriver packages. The testing process is claimed to be faster than normal Selenium tests and feels more "natural" than BrowserKit testing. Dusk will save screenshots of failures automatically and comes with helper methods, multiple window support and a Dusk-specific environment file.

tagged: laravel dusk browser testing chromedriver webdriver tool ecosystem

Link: https://laravel-news.com/laravel-dusk-is-coming


Trending Topics: