Skip to content

Unit test at the cursor is invoked twice (using keyboard shortcut only) #334

@silverqx

Description

@silverqx

I have a very weird bug in vscode, when I invoke Test: Run Test at Cursor cmd id testing.runAtCursor using keyboard shortcut (ctrl+ů c), then it runs the test under the cursor twice, look at the output:

php vendor/bin/pest --filter=^.*::(it returns 404 for invalid date route parameter)(( with (data set )?.*)?)?$ e:\htdocs\pulse\tests\Feature\MessageCountControllerTest.php --colors=never --teamcity
tests/Feature/MessageCountControllerTest.php
tests/Feature/MessageCountControllerTest.php
✅ it returns 404 for invalid date route parameter 45 ms

✅ it returns 404 for invalid date route parameter 44 ms


Tests:    1 passed (1 assertions)
Duration: 0.52s
Tests:    1 passed (1 assertions)
Duration: 0.52s

when I invoke the test using ▶️ play icon next to the unit test, then it works fine and the test runs only once:

php vendor/bin/pest --filter=^.*::(it returns 404 for invalid date route parameter)(( with (data set )?.*)?)?$ e:\htdocs\pulse\tests\Feature\MessageCountControllerTest.php --colors=never --teamcity
tests/Feature/MessageCountControllerTest.php
✅ it returns 404 for invalid date route parameter 45 ms


Tests:    1 passed (1 assertions)
Duration: 0.50s

The first run can fail if am using different .env file, like:

{
    "phpunit.phpunit": "vendor/bin/pest",
    "phpunit.environment": {
        "APP_ENV": "testing.mysql"
    }
}

That APP_ENV isn't applied to the first run, but it is a secondary problem, test should be invoked once anyway, most important feature.

Now I have also tried to invoke"Test: Rerun Last Run" cmd id testing.reRunLastRun using keyboard shortcut, and it executes the last unit test twice too.

My keybindings for "Run Test at Cursor":

Image

When I run the exact same command directly from the pwsh terminal: php vendor/bin/pest --filter=^.*::(it returns 404 for invalid date route parameter)(( with (data set )?.*)?)?$ e:\htdocs\pulse\tests\Feature\MessageCountControllerTest.php --colors=never --teamcity, then the unit test is invoked only once.

Do you have any idea where the problem can be? Thx for any advice

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