TylerLeonhardt / vscode-pester-test-adapter

MIT License
33 stars 13 forks source link

Test discovery hanging with Pester 5.2.0 #46

Open mkvideodj opened 3 years ago

mkvideodj commented 3 years ago

Hi. I tried to debug the extension, but couldn't see anything obvious - other than an error that Reset-TestSuiteState was not a recognised function. This was shown in the Pester Explorer log. When I reverted back to Pester 5.1.1, this error wasn't seen in the log. Debugging the extension I could see the promise for pesterTestRunner.loadPesterTests() being resolved - so maybe the exception is caught by the Test Explorer extension before it gets the load promise result.

The symptom is the Test Explorer in VSCode shows no tests - clicking on the Test Explorer: Reload tests icon results in the icon spinning forever.

I suspect you've been caught by a breaking change in pester. Some of my tests using modules fail in 5.2.0, so I'm happy to continue with 5.1.1 for now.

If I can provide any more details to assist you, let me know.

Thanks for this extension - attempting to debug it was my first exposure to VS Code extensions, so thanks for this experience and the instructions on your readme, even if I didn't actually manage to find the bug for you I learned how to step through a VS Code extension. :)

Thanks, Darryl

TylerLeonhardt commented 3 years ago

@nohwnd any ideas on changes in 5.2 that might have broken me?

The scripts I run are here:

https://github.com/TylerLeonhardt/vscode-pester-test-adapter/blob/master/src/powershellScripts.ts

nohwnd commented 3 years ago

It hangs for me even with 5.1.1.

https://github.com/TylerLeonhardt/vscode-pester-test-adapter/blob/master/src/adapter.ts#L63 Here you have what looks like a correct set of tests in both 5.1.1 and 5.2.0. So probably issue with firing the event and receiving it by the test explorer?

moerwald commented 3 years ago

Same problem here. Updated Pester from 5.0.4 (everything ok) to 5.2.0 -> test explorer doesn't show anything.

mikerosile commented 3 years ago

I, too, was experiencing the same issue after upgrading to Pester 5.2.0. I made some progress, though, to "fix" the Pester Test Explorer VS code plugin. I'm going to post my findings here so that others may weigh in on the changes before I (or anyone) submit a formal Pull Request.

The issue seems to be with the "Discovery Script", ~/.vscode/extensions/tylerleonhardt.vscode-pester-test-adapter-0.0.23/powershellScripts.js, due to some of the improvements made in Pester 5.2.0.

Here are the modifications I made:

The only other change that I made which seemed to help, was updating the VS Code setting for pesterExplorer.testRootDirectory to a single period (current directory) as this is the default for Pester. (See ([PesterConfiguration]::Default).Run.Path.Value)

Before submitting a Pull Request, I think it would be best to also add some logic to determine the version of Pester and then execute Pester version dependent code (e.g. Reset-TestSuiteState) based on said version. Either that or require Pester v5.2.0 for a future version(s) of the Pester Test Explorer VS code extension.

nohwnd commented 3 years ago

Ah I remember, this is using the internal hack I wrote some time ago for Tyler when he was starting this up. IIRC this was to enable running just discovery? That is built-in now in Pester 5.2.0, you just need .Run.SkipRun = $true, and via PassThru you will get the result object with all the tests.

TylerLeonhardt commented 3 years ago

I would like to try and push people to use 5.2 since this is an official API instead of the hacky script @nohwnd gave me :)

In this work we should notify the user that Pester 5.0 & 5.1 support will be removed in the future.

mikerosile commented 3 years ago

Thanks @nohwnd and @TylerLeonhardt , this helps provide the direction I need. I will take a 'stab' at updating the code and submitting a P.R.

TylerLeonhardt commented 3 years ago

If you have trouble, just let me know! Also if you can't figure out the notification part, that's ok. I can do it/provide my thoughts on that.