DEV Community

loading...

Testing Laravel Breeze Authentication

dendihandian profile image Dendi Handian ・2 min read

Laravel Breeze is a new and surprising laravel package developed by Taylor Otwell himself and released just a few days ago.

What this package provides is the more low-level auth scaffolding UI using Tailwind and AlpineJS, which the old laravel-ui auth scaffolding is using either Bootstrap, Vue or React.

Installing the package

The best way to try this package is by using a new and freshly created laravel app and installing the package using:

composer require laravel/breeze --dev
Enter fullscreen mode Exit fullscreen mode

and then scaffold the auth feature using

php artisan breeze:install
Enter fullscreen mode Exit fullscreen mode

and then also make sure to build the assets by:

npm install
npm run dev
Enter fullscreen mode Exit fullscreen mode

and then the login and register are ready to use.

laravel breeze login page

laravel breeze register page

laravel breeze dashboard page

Testing the package

My plan for this post is to make some feature/unit tests to test the login and register functionality as well as improving my PHPUnit testing skill. But laravel/breeze already provides all the test suites for us.

So, I will learn from it instead.

To enable and try the phpunit, you can see in phpunit.xml file and uncomment these lines:

...
        <server name="DB_CONNECTION" value="sqlite"/>
        <server name="DB_DATABASE" value=":memory:"/>
...
Enter fullscreen mode Exit fullscreen mode

and then you can run all tests using:

php artisan test
Enter fullscreen mode Exit fullscreen mode

Laravel Breeze is a great starting point for your laravel project if you are already comfortable using Tailwind and the purge configuration is already set to use if you build your assets for production (npm run prod).

Have fun exploring this package.

Discussion (0)

pic
Editor guide