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

jestrunner.codeLensSelector doesn't work #275

Open andyindahouse opened 2 years ago

andyindahouse commented 2 years ago

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

firsttris commented 2 years ago

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?

aligg73 commented 2 years ago

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.

firsttris commented 2 years ago

@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 commented 2 years ago

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

andyindahouse commented 2 years ago

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

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

andyindahouse commented 2 years ago

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? 🤔

firsttris commented 2 years ago

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

orofbrown commented 1 year ago

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