Error Message
PHPUnit 6.4.4 by Sebastian Bergmann and contributors.And here is the test case source code :
E... 4 / 4 (100%
Time: 200 ms, Memory: 10.00MB
There was 1 error:
1) Tests\Feature\AlphaTest::testDisplaysAlpha
Error: Call to undefined method Tests\Feature\AlphaTest::visit()
C:\wxxx\www\testxxxxxxxxx\tests\Feature\AlphaTest.php:18
ERRORS!
Tests: 4, Assertions: 9, Errors: 1.
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class AlphaTest extends TestCase
{
public function testDisplaysAlpha()
{
$this->assertTrue(true);
$this->visit('/alpha')
->see('Alpha')
->dontSee('Beta');
}
}
There is no visit method built-in by default in Laravel 5.5. It uses dusk to perform browser tests and the method visit() is not available anymore. If you still wanted to use those behavior, install laravel/browser-kit-testing package :
composer require laravel/browser-kit-testing --devMore reference about browser-kit-testing reference this:
https://github.com/laravel/browser-kit-testing#laravel-browserkit-testing
After finished installing laravel/browser-kit-testing package to your laravel 5.5 project , edit your \test\TestCase.php from the default one to this:
<?phpWhat we need to do is import Laravel\BrowserKitTesting\TestCase as BaseTestCase instead of Illuminate\Foundation\Testing\TestCase as BaseTestCase; and then default a value named $baseUrl.
namespace Tests;//use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
public $baseUrl = 'http://localhost';
}
Run your test again :
Since this is the old method, it's recommend to learn using another alternative : Laravel Dusk to run full browser tests
Reference
https://laracasts.com/discuss/channels/testing/call-to-undefined-method-viewtransactionlisttestvisithttps://stackoverflow.com/questions/42645066/acceptance-test-method-visit-undefinied
https://laravel.com/docs/5.5/dusk
No comments :
Post a Comment