Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
surgiie opened this issue Nov 2, 2024 · 1 comment

Comments

@surgiie
Copy link

surgiie commented Nov 2, 2024

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.

@surgiie
Copy link
Author

surgiie commented Nov 3, 2024

Any insight to a solution would be greatly appreciated. @owenvoke @nunomaduro

@surgiie surgiie changed the title Failed assertions dont always throw PHPUnit\Framework\ExpectationFailedException Failed assertion methods dont throw PHPUnit\Framework\ExpectationFailedException Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant