Using Sqlite database with Laravel Dusk Testing

.env.dusk.local file for dusk testing

This article covers How to Use Sqlite File database with Laravel Dusk Testing. Sqlite is pretty easy to use and does not require a database server on your development environment.

Start off by creating a separate environment for your Laravel Dusk Tests.

The configuration properties for your web application resides in .env file which is in application’s root folder, create a separate property configuration file for your dusk tests by creating another environment file with name .env.dusk.{environment}, where environment is the name your application environment.

You can now change the Db connection properties in the dusk environment file.


Next, Now create a new file with name database.sqlite inside your database folder. This file will be used by sqlite to create your tables and put data into.

If you are already using sqlite with your development environment and want to use a different sqlite database for your dusk. Then you can add a separate configuration in your database config file.

Open database.php file located at app > config directory.

Add a new entry inside connections array

'sqlite_testing' => [
    'driver'   => 'sqlite',
    'database' => database_path('sqlite.testing.database'),
    'prefix'   => '',

Now you can use this configuration in your dusk environment file.


Also you need to create sqlite.testing.database file in your database directory.

Since your sqlite database is currently empty it’s good idea to run DatabaseMigrations manually, or before each test.

Next up, Learn how to Login and Logout Users using Dusk methods.

Related Articles

Udemy Laravel Dusk Course

Laravel Dusk Beginner to Advanced

Video Course on Automation Testing, Web Scraping and Creating Bots using Dusk

> 60% OFF

Limited Time Offer

Learn More

Site Footer