firsttris / vscode-jest-runner

Simple way to run or debug one or more tests from context menu, codelens or command plalette
https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner
MIT License
265 stars 124 forks source link

Please stop removing Run | Debug when there is an error in the unit test file #361

Closed gregveres closed 5 months ago

gregveres commented 5 months ago

the extension will remove the Run| Debug options from all the functions in the file every time the code turns to an error state. Then once the error is fixed, these options come back. This causes a huge annoyance when editing the unit test file because the editing line jumps all over the place as I type text.

Let's say that I am editing a unit test function that is half way down the screen. As I edit that function, I am inevitably going to cause a syntax error that will get fixed in a couple of keystrokes. When the system detects the error, I get the obligatory red squiggle, but also vscode-jest-runner removes all the Run | debug options from all the functions in the file. This causes the line I am editing to jump up the screen a number of lines (because now the editor doesn't need to allocate space for Run | debug options). Then as soon as my next couple of characters fix the syntax error, The line I am editing jumps back down the screen to where it was.

This is extremely annoying and disconcerting to have happen while typing.

Is there a way that you can stop removing the Run | Debug options when there is a syntax error? Can you just disable them or something?

firsttris commented 5 months ago

this is the corresponding code: https://github.com/firsttris/vscode-jest-runner/blob/master/src/JestRunnerCodeLensProvider.ts#L57

there is a settings option to disable codelens: https://github.com/firsttris/vscode-jest-runner?tab=readme-ov-file#extension-settings

gregveres commented 5 months ago

I am not seeing any output in the output window from the extension. From the code snippet you highlighted, I would think that the parse isn't throwing an exception, it is just finishing and probably indicating somehwere that there was a parse error. I am guessing that the parse.root.childern is just an empty array.

I considered turning off code lens when I saw the option in the extension settings after posting the issue. But then how would you run the tests?

gregveres commented 5 months ago

Oh, I guess I would just right click on the top level describe block... Ok, I will do that. It is a little less convenient, but far more acceptable than having the code jump around.

Thanks.

firsttris commented 5 months ago

https://github.com/firsttris/vscode-jest-runner/commit/0f6b41097bf575ad739bd39df1e11b0ec3f3ba81

i think the issue was that we needed to return the previous CodeLens results if the exception happens. i just fixed it.

check version [0.4.73] and report back

gregveres commented 5 months ago

will do...

gregveres commented 5 months ago

perfect! with that change it is nice and solid now. Thank you very much for looking at it so quickly. This has really been bugging me for quite a while. I really do like your extension. Very good work.

firsttris commented 5 months ago

nice enjoy