Dusk tests without breaking live database?

Posted 1 year ago by jan_zikmund

Hi guys, I just started writing my first tests in Laravel 5.6 but I am confused about the best setup for the tests not to mess live database? I would like the tests to be available on both my local and on production so I can test with real application after I deploy a change, can this be done?

I use both Dusk and PHP Unit, and Dusk doesn't seem to support DatabaseTransactions, which would otherwise be my preferred option. If I use RefreshDatabase or DatabaseMigrations, they will afaik reset the DB, and if I don't use them, then test data will appear in live tables, so my latest assumption is, that Dusk tests cannot be run on live site, is that so or am I missing something?

I've read something about having a separate database for Dusk tests, also I could possibly mock some of the functionality but I would prefer a general solution where tests are run on whatever data are there at the moment, but the site would return to the state before test after testing is finished.

Or is there a better/recommended setup that I am missing? Thanks a lot.

Please sign in or create an account to participate in this conversation.