My test will fail if I use the RefreshDatabase property.
Without the trait test, the test passes, but the data remains in the database.
I use:
- Laravel 5.5 (new)
- Laradock: nginx mysql selenium
Tests run from the laradock workspace.
This is a test, simple, from the 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;
public function testLogin()
{
$user = factory(User::class)->create();
$this->browse(function (Browser $browser) use ($user) {
$browser->visit('/login')
->type('email', $user->email)
->type('password', 'secret')
->press('Login')
->assertPathIs('/home')
;
});
}
}
dump/sleep/dump
- it's just to see if the user has been created in the database. Is not!
The result 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:
Text approval "These credentials do not match our records." will be true, so I believe that the user was never created.
source