pester / vscode-adapter

Run PowerShell Pester Tests with Visual Studio Code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tests keep running and running tests number increases

oasaleh opened this issue · comments

commented

I have 4 tests. When I save, tests automatically run. They stay running even after they are complete (green check mark appears.) The number also increases. I only have 4 tests but the total number is 6. If I run again, both numbers (4 and 6) incrases. The only way to reset them, is to stop tests manually and then run again. But again, the tests keep running.
pester

Was about to send in an issue for this. Was seeing this too.

I think this might be incorporating the context and describe as "tests" but their pass result isn't showing, I'll try to look into when I have time.

I think this might be incorporating the context and describe as "tests" but their pass result isn't showing, I'll try to look into when I have time.

I can confirm that Context blocks are interpreted as tests and somehow Pester (or the adapter, I'm not sure) waits for them to complete forever.

Removing Context blocks from tests is a possible workaround, albeit an annoying one.

I don't use context blocks at all and I have the same problem.
Example:

Describe "Test" {
    BeforeAll {
        # Add a function
        . .\test.ps1
    }

    It "Test should be true" {
        Mock ....
        Get-Test | Should -BeTrue
        Should -Invoke Get-Test -Times 1 -Exactly
    }
    }

Adding a context block, does not change anything.

Such a great extension but this bug makes it unusable.
I don't really write much Typescript but I'd be willing to try and fix this, does anyone have any pointers/ideas where to start or what might be causing the issue?

My summer has me tied up in other priorities but I hope to be able to dedicate some more time to cleaning things up in the fall.

The core issue is that to keep things fast, everything has to be async, and on occasion, things don't get cleaned up correctly between runs because it's very difficult to correlate a "test run" through the maze of going to PowerShell and back and parsing the output, so sometimes the count gets off as a result, I plan to do a refactor which should help with that and help with the issues that come up with interrupting a run and starting anew, etc.

The PR I just submitted makes a quick fix to the issue by ending the test run when Pester ends. It works on my use case. Hope it helps.

@oasaleh @johlju @ghost @FLeven can you test this VSIX and confirm if it fixes your issue?
https://github.com/pester/vscode-adapter/suites/10017671926/artifacts/488197337

To install just unzip it somewhere, go into vs code, hit F1, and then type "install from vsix" and browse to it and then reload vscode.

Awesome work @antoinemartin. @JustinGrote happy to see this merge.

With the proposed change the test run seems to stop correctly, the blue progress bar no longer keeps moving after test run ends. It also starts to count from zero on each run. The only thing that I noticed is that at the end of the run the number of passed tests and total test revert to zero directly; see 0/0 test passed (0.00%) at the top at the end of the run. It should probably only reset when a new run starts? But that could be fixed in another PR.

PesterTestAdapter-issue#115

I submitted a new issue here - it probably has nothing to do with this change but just want to mention it as I'm now running the VSIX with proposed change above; #131