Database transactions not being cleared after test
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\User;
use Illuminate\Support\Facades\DB;
class PlotsTest extends DuskTestCase {
use DatabaseTransactions;
public function setUp() {
Parent::setUp();
$this->user = User::find(1);
}
/**
* @test
* @group plots
*/
public function loginAsRoot() {
$this->browse(function (Browser $browser) {
//$this->user = User::find(1);
$browser->loginAs($this->user)
->visit('/plots')
->assertSee('Deed Plan No');
});
}
/**
* @test
* @group plots
*/
public function addNewPlot() {
$this->browse(function (Browser $browser) {
$browser->visit('/plots')
->click('#add-plot')
->select('#plot-type-id', '1')
->type('#grant-number', 123456852)
->type('#deed-plan-no', 74592169)
->type('#area', 2.5)
->select('#area-type-id', '1')
->type('#term', 33)
->type('#term-from', '1991-05-09')
->select('#granted-to', '2')
->select('#rent-type-id', '1')
->click('#save-plot')
->whenAvailable('.swal2-container', function ($modal) {
$modal->assertSee('Plot has been successfully created')
->press('OK');
});
});
}
}
@wamae One option is to rollback the database after each test and migrate it before the next test
use DatabaseMigrations trait that will automatically handle this for you
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use App\User;
use Illuminate\Support\Facades\DB;
class PlotsTest extends DuskTestCase {
use DatabaseMigrations;
}
Please sign in or create an account to participate in this conversation.