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
264 stars 124 forks source link

Fix when properties in test name #301

Closed Gkleinereva closed 1 year ago

Gkleinereva commented 1 year ago

Fixes #299

Full disclosure: I've never worked on this, or any, VS Code extension before. I'm also not a pro at the jest command line. No worries if this needs more work!

There are still a few weird edge cases that I'm not sure how to get around. It seems to me that the core of the problem is that VSCode passes a string to the extension handlers, regardless of whether or not a string (as opposed to a symbol) is used in the test name.

For example, the following test will not be captured by the CodeLens option in the extension after my change:

it('has.name randomly in it', () => {...});

or maybe a bit more realistically, this one would not be captured either:

it('The method MyClass.prototype.myMethod exists', () => {...});

On the whole, I still think this is a considerable improvement from current functionality, and will allow me to use the extension in work projects where I currently can't. :)

firsttris commented 1 year ago

Hey @Gkleinereva,

thx for your contribution. i will do some testing and get back to you.

dont worry im also a junior in vscode extensions.

Gkleinereva commented 1 year ago

Hey @firsttris I know you probably have a lot of other stuff to do, but do you have some idea of when this might be reviewed and/or merged? Thanks :)

Gkleinereva commented 1 year ago

Hey @firsttris any thoughts on getting this merged?

firsttris commented 1 year ago

its on my list of stuff i need to get done.

i also need to setup a new vsce token to publish a new version.

hopefully i can squeeze it in this week.

Gkleinereva commented 1 year ago

Thanks for the update :)

firsttris commented 1 year ago

i made some tests and could verify that using properties in tests names is now possible. you did it. great work.

Gkleinereva commented 1 year ago

Woohoo! Thanks for reviewing/merging @firsttris!

firsttris commented 1 year ago

since this change "Run Jest" does no longer run the whole file if you right click and choose "Run Jest" outside an it().

it seems like a bit of an edge case, but do you think its possible to restore this functionality ?

domsleee commented 1 year ago

It looks like a simple fix, receivedTestName can be undefined if you click outside the file https://github.com/firsttris/vscode-jest-runner/commit/6d2697e5cdb3b03e6c328d0c311dcc6d819b24ee#diff-3294a832ea2276e554177e0b3007cc2d401c082912c7fbde49fa09141bf1aed1R104

Gkleinereva commented 1 year ago

@firsttris thanks for letting me know - it'll take me a little while to figure out the development environment again, but I should be able to submit a PR tomorrow or Friday.

@domsleee thanks for the tip!

firsttris commented 1 year ago

hey @Gkleinereva dont worry. @domsleee already provided a fix https://github.com/firsttris/vscode-jest-runner/pull/325

its already in the latest version