Search code examples
phplaravelsqlitetestinglaravel-dusk

Login test with laravel dusk


I started browser testing with laravel dusk. Using a test database (sqlite), creating a user with a model factory and using the Browser::loginAs method worked. But when I try to simulate a real login, I get an Error:

General error: 1 no such table users.

I have a .env.dusk.local file with and specified DB_CONNECTION=sqlite and DB_DATABASE=:memory: I also tried it with a sqlite file. Then I got the error

Database (tests.sqlite) does not extis.

I've read that the problem could be, dusk and the application open different connections. How should I configure the database connections to get this working?


Solution

  • The problem is you cannot use :memory: database while running Laravel dusk. Because dusk and testing server are running on separate processes. Dusk can't access to database created on development server.

    See my answer here https://stackoverflow.com/a/50376781/7917269