Dusk environment

Posted 6 months ago by NicolasMeyer

Hello all!

I'm building a new app using Laravel 5.7, and started recently to use Dusk for testing, coupled with Jenkins for CI.

My main problem at the moment is how to specify which database to use. I'll explain.

I created a .env.testing file to specify the connection, and run dusk with --env=testing. I use the 'refreshDatabase' trait in the test. I don't want to use migrations between each test as my set of migrations is pretty heavy and contains a lot of inserts. Just once before is enough.

And here's what happens: There are initial migrations run against my testing database. I was under the impression that refreshDatabase was preventing that, but I might be wrong. However, from that, I am 100% sure that the beginning of the process is against the test database.

My test is a register test. It works great. But only the first time. The second time, the system tells me the user email address is already taken. And indeed, at the end of the test, my regular database contains the new user... and my test database is empty.

So if anyone has a clue on what's happening, or care to share some light, I would be very grateful! Is this coming from the trait? What else have I done wrong?

Thanks a lot for any help!

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