My test will fail if I use RefreshDatabase trait.
Without the trait -- test will pass but data remains in database.
I'm using:
- Laravel 5.5 (a fresh one)
- Laradock: nginx mysql selenium
Tests are being running from a laradock's workspace.
This is the test, simple, from an official documentation.
<?php
namespace Tests\Browser;
use App\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class LoginTest extends DuskTestCase
{
use RefreshDatabase;
/**
* A Dusk test example.
*
* @return void
*/
public function testLogin()
{
$user = factory(User::class)->create();
// dump('wait...');
// sleep(15);
// dump('go!');
$this->browse(function (Browser $browser) use ($user) {
$browser->visit('/login')
->type('email', $user->email)
->type('password', 'secret')
->press('Login')
->assertPathIs('/home')
;
});
}
}
dump/sleep/dump
is just to see if the user has been created in the database. It's not!
The result of php artisan dusk
is:
There was 1 failure:
1) Tests\Browser\LoginTest::testLogin
Failed asserting that '/login' matches PCRE pattern "/^\/home/u".
/var/www/vendor/laravel/dusk/src/Concerns/MakesAssertions.php:53
/var/www/tests/Browser/LoginTest.php:32
/var/www/vendor/laravel/dusk/src/TestCase.php:92
/var/www/tests/Browser/LoginTest.php:34
NOTE:
Asserting text "These credentials do not match our records." will be true, so I believe that user has never been created.
sqlite :memory:
connection?