Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

When using Components, always getting a "call to a member function collect() on null" error #50

@nie7321

Description

@nie7321

When I use a component and a $browser->within(new MyComponent, . . .), I'm always getting an error:

    public function test_dashboard_available()
    {
        $this->browse(function (Browser $browser) {
            $browser->within((new Multiselect('#search-status-selector')), function ($browser) {
                $browser->clickOption(3);
            });
        });
    }

Resulting in:

Error: Call to a member function collect() on null

/home/vagrant/code/dusk-dashboard/src/Dusk/Concerns/MakesAssertions.php:262
/home/vagrant/code/a-nice-project/tests/Browser/Components/Bootstrap/Multiselect.php:39

I think the problem is that the Laravel\Dusk\Browser is just doing a new static() to make a Browser for the component -- it doesn't know that it needs to call setActionCollector().

I can work around the bug by passing the BrowserActionCollector through from the test case, and then calling setActionCollector myself before the component uses the browser instance, but this is kinda gross.

I'm not sure what the right way to solve this is!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions