Skip to content
Learning with Manjeet
  • Home
  • Javascript
  • CSS
    • Introduction to Bootstrap
    • Bootstrap Components
  • HTML
  • PHP
  • Project Management
    • What is Project Management
    • Improve team leadership skills
  • Cyber Security
    • What is cyber security
    • Cyber security best practices
    • Token-based authentication
  • Blog
    • Development
    • Docker
    • Testing
    • JAVA
    • Domain
    • Laravel
    • ECommerce
    • Interview Questions
    • Website Design
Search

How to create laravel dusk test from Login page?

/ Laravel, Testing

create laravel LoginTest class using below artisan command:

php artisan dusk:make LoginTest
<?php
 namespace Tests\Browser;
 use Illuminate\Foundation\Testing\DatabaseMigrations;
 use Laravel\Dusk\Browser;
 use Tests\DuskTestCase;
 use App\Models\User;

 class LoginTest extends DuskTestCase
 {
     /**
      * A Dusk test for user login.
      *
      * @return void
      */
     public function testUserLogin()
     {

     $user = factory(User::class)->create([
              'email' =>'[email protected]',
          ]);
     $this->browse(function (Browser $browser) use ($user) {        
    $browser->visit('/login')                 
       ->assertSee('Login')                
       ->value('#email', $user->email)                
       ->value('#password', $user->password)                        ->press('Login')                
      ->assertPathIs('/home')                         ->assertSee('You are logged In!');     
     }); 
} 
 }

Now run below command to test the test cases:

php artisan dusk
Post navigation
← Previous Post
Next Post →

Recent Posts

  • What is DOM in javascript?
  • What are object prototypes in javascript?
  • Information technology best practices
  • Cloud Computing Interview Questions
  • Code Management and Collaboration
  • Next.js vs React.js: A Deep Dive into the Features and Comparisons”
  • The Top Build Tools for Frontend Development
  • What are higher Order Functions in JavaScript?
  • What is React js? Why React js is so popular?
  • What is single sign-on?

Categories

  • AWS
  • CSS
  • Development
  • Docker
  • Domain
  • ECommerce
  • Hosting
  • HTML
  • Interview Questions
  • JAVA
  • Javascript
  • Laravel
  • NODE
  • PHP
  • Scripting
  • Testing
  • Vue
  • Website Design
  • Wordpress

Australian Hosting Provider – Ventraip

Would You Like To Start A Project With Me?

Contact Me

Find best solutions for your technical problems on my website.

If you need website design, development and support services, visit my portfolio here.

Linkedin-in Skype Envelope Github Stack-overflow

If I helped you solve your technical problem and you would like to thank me, you can buy me a coffee here. :)

Links

  • Home
  • About
  • Blog
  • Contact
  • Disclaimer

Get In Touch

  • Brisbane, Australia
  • [email protected]

learningwithmanjeet.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

Copyright © 2023 Learning with Manjeet. Site by Website Design Brisbane