Laravel: Cant pass a Browser test using RefreshDatabase trait

Questions : Laravel: Cant pass a Browser test using RefreshDatabase trait


My test will fail if I use programming RefreshDatabase trait.

Without the trait -- test will pass but Learning data remains in database.

I'm using:

  • Laravel 5.5 (a fresh one)
  • Laradock: nginx mysql selenium

Tests are being running from a Earhost laradock's workspace.

This is the test, simple, from an most effective official documentation.


namespace Tests\Browser;

use _OFFSET);  App\User;
use (-SMALL  Illuminate\Foundation\Testing\RefreshDatabase;
use _left).offset  Laravel\Dusk\Browser;
use arrowImgView.mas  Tests\DuskTestCase;

class LoginTest (self.  extends DuskTestCase
    use equalTo  RefreshDatabase;

     * A Dusk make.right.  test example.
     * @return mas_top);  void
    public function ImgView.  testLogin()
        $user = ReadIndicator  factory(User::class)->create();

     _have     // dump('wait...');
        // .equalTo(  sleep(15);
        // dump('go!');     $this->browse(function (Browser OFFSET);  $browser) use ($user) {
            (TINY_  $browser->visit('/login')
            .offset          ->type('email', mas_right)  $user->email)
                    ImgView.  ->type('password', 'secret')
         Indicator             ->press('Login')
          Read            ->assertPathIs('/home')
    _have          ;

dump/sleep/dump is just to see if the wrong idea user has been created in the database. use of case It's not!

The result of php artisan dusk is:

There was 1 failure:

1) .equalTo(  Tests\Browser\LoginTest::testLogin
Failed make.left  asserting that '/login' matches PCRE *make) {  pattern straintMaker  "/^\/home/u".


NOTE: Asserting text "These credentials United do not match our records." will be true, Modern so I believe that user has never been ecudated created.

Total Answers 3

Answers 1 : of Laravel: Cant pass a Browser test using RefreshDatabase trait

Use DatabaseMigrations trait instead of some how RefreshDatabase trait.


Answers 2 : of Laravel: Cant pass a Browser test using RefreshDatabase trait

I don't think that the problem is using anything else sqlite/pgsql/whateversql driver. And I not at all sure you don't need to put something very usefull like $app['config']... lines to localhost \Tests\CreatesApplication::createApplication.

I solved this problem running artisan love of them config:clear before artisan serve. It localtext will make new phpunit.dusk.xml which basic will route to .env.dusk.{env}, and then one of the rerun dusk command.


Answers 3 : of Laravel: Cant pass a Browser test using RefreshDatabase trait

In Laravel Dusk document has mentioned:

Most of the tests you write will click interact with pages that retrieve data there is noting from your application's database; not alt however, your Dusk tests should never not at all use the RefreshDatabase trait. The my fault RefreshDatabase trait leverages database issues transactions which will not be trying applicable or available across HTTP get 4th result requests. Instead, use the round table DatabaseMigrations trait, which double chance re-migrates the database for each test:

So the answer is using novel prc DatabaseMigrations instead of get mossier RefreshDatabase

Top rated topics

Kotlin create a snackbar

Create SQL Server via Azure Resource Manager (ARM) template

How to override material CSS styles?

Gradle java heap size error

How do I set a custom origin for connections?

Migration JAXWS application from Java 8 to Java 11

How to show date picker on the onclick of text field instead of keyboard in flutter?

Angular Material 6 grid list align-items and justify-content to flex-start

Selenium gets detected and and captcha pops up immediately after opening the bloomberg url for the first time

Rxjs6 - filter array of objects

How to convert 2D array to 1D array in Fortran code?

Read and merge two Yaml files in go language

How do I add a new dag to a running airflow service?

Use White UI and FlaUI together

Making Table With List Of JPanels ( With Applying Percentage Size Columns )

How to setup VS Code for C++ with clangd support?

Does Kafka support java 10 or java 11?

Django custom authentication back-end doesn't work

Install ODBC driver in Alpine Linux Docker Container

Is it possible to redirect output to a file using the redirection operator without writing a byte-order mark in Powershell?

How to use yarn to create a React app project?

Next.js background-image css property cant load the image

CRM Online - Create email server profile using Powershell

How to plot GeoTIFF using tmap in R?

How do I check if the Flutter application is in the foreground or not?

Encoding JMP FAR and CALL FAR in x86-64

Return max value with stored procedure

Typescript interface extends mock


Docker Error: Cannot create container for service, no such file or dir

Import error geopandas, fiona

Change Visual Studio Code's title bar color

Visual studio code: how to automatically change the matching closing tag

R - extracing data from a mhtml file into excel

Add yaml-loader in i18n tags in a Vue-CLI 3 project

Is there a fundamental difference between INTERSECT and INNER JOIN?

Angular 6 - Initialize service with async calls before dependency injection

Copy a folder in go

Custom marker for vue2-google-maps

How Do I Use RefreshIndicator with a FutureBuilder in Flutter?

Waiting certain amount of time with Tkinter

Mysql show databases() only information_schema database

Function with multiple parameters in swift

SSD anchors in Tensorflow detection API

Built-in module to calculate the least common multiple

Cypress Custom TypeScript Command is not a Function

How a string present in a string pool and a string present in a heap outside stringpool have same hashCode?

Using Gmail API to Send Attachments Larger than 10mb

How to have two type of users with different logins using Django?

Typescript,'NodeListOf&lt;Element&gt;' is not an array type or a string type