Laravel allows you to reset your db after each test, using the DatabaseMigrations trait, this way you don't have to worry about doing it manually
Note, try to wrap your code between ` ` so it's nicely formatted.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, First time posting :-) I am using a mysql test database (as I have views and procedures in the database). When running "php artisan test" the first time my tests pass. If I re-run tests, almost all fail. https://laracasts.com/discuss/channels/laravel/how-to-php-artisan-dbwipe-the-testing-database#
I have to drop all tables and views in the mysql testing database before the tests pass again!
I have found php artisan db:wipe --database=mydb_testing --drop-views command but get an
"InvalidArgumentException - Database connection [mydb_testing] not configured." error.
The testing database name is configured in the .env.testing config file. I though about trying php artisan db:wipe --database=mysql... but that might drop the production database as the connection type/name is "mysql". for both!
Content of .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydb
DB_USERNAME=xxxxxx
DB_PASSWORD=xxxxxxxxxxxxxxxxxxxx
Content of .env.testing
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydb_testing
DB_USERNAME=xxxxxx
DB_PASSWORD=xxxxxxxxxxxxxxxxxxxx
How do I run the artisan db:wipe command to drop tables and views from the testing database?
Kind regards Ritchie
Laravel allows you to reset your db after each test, using the DatabaseMigrations trait, this way you don't have to worry about doing it manually
Note, try to wrap your code between ` ` so it's nicely formatted.
Please or to participate in this conversation.