vscode-jest-runner icon indicating copy to clipboard operation
vscode-jest-runner copied to clipboard

jestrunner.codeLensSelector doesn't work

Open andyindahouse opened this issue 3 years ago • 8 comments

Hi!

I've modified this setting:

"jestrunner.codeLensSelector": "**/*-{test,acceptance-test}.{js,jsx,ts,tsx}"

But I can't see "run jest option" in explore/context:

Captura de Pantalla 2022-09-21 a las 13 27 28

It looks like default value can't be overwritten

andyindahouse avatar Sep 21 '22 11:09 andyindahouse

unsure why it is not working for you.

here is the source code: https://github.com/firsttris/vscode-jest-runner/blob/24bb70702e47943d855bee8724286bab9f9317da/src/extension.ts#L65

this is the provided default value: https://github.com/firsttris/vscode-jest-runner/blob/master/package.json#L96

which is working otherwise it would not work at all wouldnt it?

firsttris avatar Sep 22 '22 07:09 firsttris

Perhaps related is what I have been observing:

If I use this in my test code: import testJSON from '../../../test/config.json'; ... the 'Run | Debug' codelenses appear in my code. If I include this import assertion however, which is supported in Node v18:

import testJSON from '../../../test/config.json' assert { type: 'json' }; ...the codelenses disappear. @andyindahouse Is there anything in your actual test which not widely supported yet?

@firsttris I'd like to keep using import assertions, is there something in the configuration of the extension which will allow for this?

Thanks.

aligg73 avatar Sep 23 '22 17:09 aligg73

@aligg73 probably the babel parser for jest used by the extension (provided by jest-editor-support) is not supporting this feature yet and crashing as a result.

firsttris avatar Sep 23 '22 17:09 firsttris

Jest-editor-support has unit tests for various features / plugins. you can check if this feature is already included.

firsttris avatar Sep 23 '22 17:09 firsttris

which is working otherwise it would not work at all wouldnt it?

The default value is working "**/*.{test,spec}.{js,jsx,ts,tsx}"

andyindahouse avatar Sep 30 '22 09:09 andyindahouse

Perhaps related is what I have been observing:

If I use this in my test code: import testJSON from '../../../test/config.json'; ... the 'Run | Debug' codelenses appear in my code. If I include this import assertion however, which is supported in Node v18:

import testJSON from '../../../test/config.json' assert { type: 'json' }; ...the codelenses disappear. @andyindahouse Is there anything in your actual test which not widely supported yet?

@firsttris I'd like to keep using import assertions, is there something in the configuration of the extension which will allow for this?

Thanks.

Nope, there aren't anything unusual. It's a normal test in TS.

Furthermore if I change the name of my test to fit in the default glob format, It works fine.

@firsttris Have you ever tried to change the default case? Does it works for you? 🤔

andyindahouse avatar Sep 30 '22 10:09 andyindahouse

you can run the extension in development mode (see readme.md)

check if it crashes inside this try-catch

https://github.com/firsttris/vscode-jest-runner/blob/master/src/JestRunnerCodeLensProvider.ts#L58

firsttris avatar Sep 30 '22 13:09 firsttris

+1 overriding the default glob pattern only works if I prefix with **/

orofbrown avatar Apr 17 '23 15:04 orofbrown