Thursday, August 10, 2017

[Laravel5.5][Dusk][Resolved] Default ExampleTest return Did not see expected text [Laravel] within element [body] message


Error message :
C:\wamp\www\exampleapp>php artisan dusk
Warning: TTY mode is not supported on Windows platform.
PHPUnit 6.4.4 by Sebastian Bergmann and contributors.
[1110/163504.684:ERROR:devtools_http_handler.cc(786)]
DevTools listening on 127.0.0.1:12327
F                                                                   1 / 1 (100%)
Time: 25.15 seconds, Memory: 12.00MB
There was 1 failure:
1) Tests\Browser\ExampleTest::testBasicExample
Did not see expected text [La] within element [body].
Failed asserting that false is true.
C:\wamp\www\exampleapp\vendor\laravel\dusk\src\Concerns\MakesAssertions.php:2
74
C:\wamp\www\texampleapp\vendor\laravel\dusk\src\Concerns\MakesAssertions.php:2
45
C:\wamp\www\exampleapp\tests\Browser\ExampleTest.php:22
C:\wamp\www\exampleapp\vendor\laravel\dusk\src\TestCase.php:92
C:\wamp\www\exampleapp\tests\Browser\ExampleTest.php:23

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

Source code:

ExampleTest.php
<?php

namespace Tests\Browser;

use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;

class ExampleTest extends DuskTestCase
{
    /**
     * A basic browser test example.
     *
     * @return void
     */
public function testBasicExample()
{
    $this->browse(function ($browser) {
        $browser->visit('/')
            ->assertSee('Laravel');
    });
}
}

Solution

I found amend the APP_URL value in .env file can solve the problem. For example, if application url to view your root page is this :
http://localhost/exampleapp/public/

and then your APP_URL value in .env should be http://localhost/testcaseapp/public :



Perform the test again:


Reference

https://laravel.com/docs/5.5/dusk

1 comment :

  1. Get custom Laravel development services from a leading Laravel Development Company based in India & USA to build modern and robust solutions. Contact us for Information for Pricing: +91-9806724185 or Contact@expresstechsoftwares.com

    ReplyDelete