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

Test skipped if "describe" or "it" is not a string #241

Closed andreviallon closed 10 months ago

andreviallon commented 2 years ago

Hello,

I have an issue when running tests in a file where either the name of a "describe" or a "it" is not a string but instead a function.name. In the example bellow I use sum.name as the name for the describe (line 3 in sum.spec.ts) and all tests will be skipped when running tests through the extension.

Does not work:

Screenshot 2022-03-04 at 13 50 43

Works:

Screenshot 2022-03-04 at 13 51 15
AbrahamLopez10 commented 2 years ago

We're having the same issue, if this could be fixed it would be awesome, as using the function names provides a much easier and more consistent way of naming test suites for a given method, and makes renaming the test seamless when the method name changes, as it's just using the reference to the method name.

mhombach commented 2 years ago

Does the jest-cli support escaping currently? If not, this bug might be needed to be fixed in the jest-cli, not vscode :/

andreviallon commented 2 years ago

Does the jest-cli support escaping currently? If not, this bug might be needed to be fixed in the jest-cli, not vscode :/

Well, the extension works when running tests for the whole file in watch mode, so I guess it's bug

mhombach commented 2 years ago

Does the jest-cli support escaping currently? If not, this bug might be needed to be fixed in the jest-cli, not vscode :/

Well, the extension works when running tests for the whole file in watch mode, so I guess it's bug

Testing the full file is not a problem. The problem is, that, when testing specific tests from a test-file, the name of the test-case is passed as parameter to the jest-cli. If this name however contains certain quotation-chars, this is basically ending the parameter too early. I'm not sure if the jest-cli currently supports escaped quotes in its cli-params? I've had this problem with different vscode-extensions, they all had trouble with certain quotes :/

domsleee commented 10 months ago

I think .name is supported by #301?

The code replaces the .name suffix with the empty string here:

https://github.com/firsttris/vscode-jest-runner/blob/b5097b30d55e493203fbc15df37898df48581594/src/util.ts#L101-L102

Please re-open if I'm mistaken 👍