Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

luisten's avatar

Call to undefined method ViewTransactionListTest::visit()

I'm just getting started with testing and following the series here and on TestDrivenLaravel however when I try to create my first test I immediately get the following error:

PHP Fatal error:  Call to undefined method ViewTransactionListTest::visit()

This is the code for my Test file:

class ViewTransactionListTest extends TestCase
{
    /** @test */
    function user_can_view_tx_list() {
        // Act
        $this->visit('/home');

        // Assert
        $this->see('Latest Transactions');
    }

}

I'm using Laravel 5.4 and I have phpunit 5.7.14 installed globally on a Windows machine. When I run using ./vendor/bin/phpunit I get the same error. I also tried running phpunit from Homestead and see the same error.

I also checked out the answer in https://laracasts.com/discuss/channels/testing/visit-and-see-and-all-that-not-working but installing the Integrated testing package seems like it isn't necessary for the latest versions of Laravel.

What am I missing?

0 likes
3 replies
tomopongrac's avatar
Level 51

Laravel 5.4 uses dusk

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

Try with

$this->browse(function ($browser) {
            $browser->visit('/home')
                    -> assertSee('Latest Transactions');
        });

I think that TestDrivenLaravel is for Laravel 5.3

4 likes
luisten's avatar

Thanks! This is exactly it.

For those that upgraded from 5.3 to 5.4 there are some additional steps that don't seem to be included in the upgrade guide. Some additional files need to be changed/created in the /tests directory. Further instructions can be found here: https://github.com/laravel/dusk/issues/40

1 like
connor11528's avatar

Dusk requires a lot of changes to your tests that is different from the code Adam writes in the course. To get tests working in a similar manner using >= Laravel 5.5 you can use:

composer require laravel/browser-kit-testing --dev

Full setup instructions here (it's not too bad): https://github.com/laravel/browser-kit-testing

I have the tests running in functional dir using Laravel 5.6!

Please or to participate in this conversation.