Laravel TestTools

by Marcel Pociot — on

Laravel TestTools

Testing a Laravel application really is an easy task - the "Integrated" package from Jeffrey Way, that later got merged into the core framework is fantastic and helps you with the otherwise cumbersome task of testing and interacting with your application. But still - are you actually using tests?

A lot of times people really love the idea of tests, but simply don't get their asses up to start using them in their own projects. That's why I created a chrome extension that hopefully saves you some time when you need to test your app.

Get the extension



Using the chrome extension

The chrome extension allows you to "record" your activity on the page you're currently viewing and translates these activies into Laravels testing syntax.

Take a look at the extension in action.

With just a few clicks, you just magically created a integration test for your registration process.

But wait! There's more you can do!

If you, for example, want to generate dynamic data within your test, you can do this by using the Laravel TestTools context menu. The menu gives you access to some handy faker methods to generate emails, names or words on the fly.

Limitations

You can not test your Javascript/VueJS/AngularJS single page application with this. Even though the extension will generate the test code for you it will not work with Laravel. That's because when Laravel is running these tests it doesn't have Javascript. What happens, when Javascript runs your tests is that it simulates a GET/POST/whatever request to the specified URL and fetches and parses the resulting HTML DOM. That DOM is then used to modify input fields, search text and submit forms.

If you really need to test Javascript in a browser - take a look at "Selenium". Jeffrey Way has you covered - https://laracasts.com/series/intuitive-integration-testing/episodes/5

This is awesome - can I help you?

You sure can - the source code is available on Github. This is the very first version of the Laravel TestTools extension, so there might be bugs, quirks or unexpected behavior. If you need any help, get in touch with me via Twitter or create an issue on the Github repository.