The title says it all. I would like to know how to properly set up a new Laravel 5.4 project with Dusk, using an in-memory SQLite database.
I can run the tests, but I get an error: "No such table: users"
I have added a .env.dusk.local
which contains
APP_ENV=local
APP_KEY=RANDOM_STRING_HERE
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://laravel54.dev
DB_CONNECTION=sqlite
DB_DATABASE=':memory:' // I've also tried just :memory: and also adding these details to the config/database.php file but to no avail
This is the test I am running (directly from the docs)
<?php
namespace Tests\Browser;
use App\User;
use Tests\DuskTestCase;
use Laravel\Dusk\Chrome;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class LoginTest extends DuskTestCase
{
use DatabaseMigrations;
public function test_login_page()
{
$user = factory(User::class)->create();
$this->browse(function ($browser) use ($user) {
$browser->visit('/login')
->type('email', $user->email)
->type('password', 'secret')
->press('Sign in')
->assertPathIs('/home');
});
}
}
What am I missing?
You cannot.
The important thing to note is that for this kind of end-to-end test, Dusk will not be able to control the environment as it will open a separate process. An in-memory SQLite would only exists under Dusk process and the real-browser hitting the application would have no knowledge of the database Dusk created, making it impossible to assert anything in the database.
https://github.com/laravel/dusk/issues/110
https://github.com/laravel/dusk/issues/73
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With