Skip to content

Failed assertion methods dont throw PHPUnit\Framework\ExpectationFailedException  #41

@surgiie

Description

@surgiie

Certain assertions/browser action methods throw the following error when they fail:

image

While others throw a more expected exception type:
image

Reproduction

  • Create new zero app:
composer create-project --prefer-dist laravel-zero/laravel-zero example-cli
  • Install dusk component:
./application app:install console-dusk
  • Install chrome driver (and chrome if you havent already)
  ./application dusk:chrome-driver
  • Add code to command and call command:
public function handle(): void
{
    $this->browse(function ($browser) {
        $browser->visit('https://laravel-zero.com')
            ->assertSee('Something that makes this fail.');
    });
}

This will throw the first exception as noted above.

  • Change the assertSee method to assertTitle and re run your command, this should now produce an expected ExpectationFailedException exception.

From what I can tell, the first seems to be caused by the lack of some php unit configuration/initialization process. It's unclear what I have to add to my laravel zero application for the the assertion exception type to be correct here. Im uncertain what all assertion methods are affected as well, it seems some work as expected and others dont. The first exception is not ideal for error handling within my application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions