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

Breaking change in tests in v10.17.1 regarding console commands #48066

Closed
jkniest opened this issue Aug 14, 2023 · 2 comments
Closed

Breaking change in tests in v10.17.1 regarding console commands #48066

jkniest opened this issue Aug 14, 2023 · 2 comments

Comments

@jkniest
Copy link

jkniest commented Aug 14, 2023

Laravel Version

10.17.1

PHP Version

8.2.8

Database Driver & Version

No response

Description

Hello,

In this PR #47928 the logic behind the run command was changed in the Artisan command.

This update caused my tests to fail.

Currently I have the following test using Pest.

    artisan(UserAddCommand::class, ['email' => '[email protected]'])
        ->expectsQuestion('What is the name of the new user?', 'Bob Bauer')
        ->expectsQuestion('What is the password of the new user?', 'secret123')
        ->expectsOutputToContain('User created successfully!')
        ->assertOk();

This worked fine before the update, but afterwards I am getting the error:

Output does not contain "User created successfully."

The actual console command prints stuff like this using Termwind:

        render(
            <<<HTML
    <div class="py-1">
        <div class="px-1 bg-green-600 font-bold">Success</div>
        <em class="ml-1 text-green-600">
            User created successfully.
        </em>
    </div>
HTML
        );

This only happens if more than one test is being executed. One test itself is fine, but as soon as two tests are presend the second one will fail!

Reverting the change in the Command.php class makes my tests green again.

Steps To Reproduce

  1. Copy the code snippets from above into a fresh laravel install < 10.17.1
  2. Run the tests and see that everything is green
  3. Update to laravel >= 10.17.1
  4. Tests will fail
@jkniest
Copy link
Author

jkniest commented Aug 14, 2023

Also as a follow up, when adding $this->info instead of termwind it works again. But it prints the termwind stuff during tests:

CleanShot 2023-08-14 at 18 46 40

@driesvints
Copy link
Member

Hey there. I have to say that console output isn't covered by our BC promise. It can totally happen that the text changes during minor or patch releases.

I do see you assert on User created successfully! and the error says User created successfully. (notice the exclamation mark difference).

If it's only the matter of changing the exclamation mark I'd just update your tests. Sorry you got caught with this.

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

2 participants