magic-test/magic-test-laravel

Breaking with one line chained

dansysanalyst opened this issue · 4 comments

Hi Mateus,

I believe this is related to what we already talked about, but it has happened to me because I was not attentive to linebreak and then ->magic(). I decided to write here just to have it.

When I make an assertion with a one line chained method $browser->visit('/')->magic();

<?php

namespace Tests\Browser;

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

class danTest extends DuskTestCase
{
    /**
     * A Dusk test example.
     *
     * @return void
     */
    public function testExample()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/')->magic();
        });
    }
}

....It results in:

<?php

namespace Tests\Browser;

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

class danTest extends DuskTestCase
{
    /**
     * A Dusk test example.
     *
     * @return void
     */
    public function testExample()
    {
        $this->browse(function (Browser $browser) {
                    ->assertSee('Language')
            $browser->visit('/')->magic();
        });
    }
}

@dansysanalyst out of curiosity, can you check which version you have under your composer.lock file?
This is an issue that was fixed when I implemented the AST parser.

composer.lock

 {
            "name": "magic-test/magic-test-laravel",
            "version": "v0.13",
            "source": {
                "type": "git",
                "url": "https://github.com/magic-test/magic-test-laravel.git",
                "reference": "42f15af0681e941981fc911aae2bd99b3e73a8af"
            },

composer.json

        "magic-test/magic-test-laravel": "^0.13.0",

@dansysanalyst sorry for the delay Dan — can you try with 0.3.0?

Hi Mateus,

Sorry for not testing promptly. I confirm it works.

It went from:

 public function testBasicExample()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/')->magic();
        });
    }

to:

    public function testBasicExample()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/')->assertSee('beginning');
        });
    }

Running:

        "magic-test/magic-test-laravel": "^0.14.0",

Thank you very much!