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

Cannot use import satement outside a module #359

Closed cesar-rl closed 5 months ago

cesar-rl commented 5 months ago

I'm using Typescript and I'm getting this error just out of the box. When I run from the CLI, jest runs ok.

Does someone knows how to allow imports using this extension?

firsttris commented 5 months ago

Hey the extension is simply generating a command which is executed from CLI. So it should be pretty much the same as when you execute Jest from CLI.

there is nothing which prevents you from using import statements.

cesar-rl commented 5 months ago

I think I got the problem.

In my project, config files are not in the root folder, so I need to pass the --config <PATH> to Jest in the CLI. Is there a way to inform the extension the path to the config file? Or to add the --config <PATH> to the Jest CLI calls?

In the CLI: image

Using the extension: image

cesar-rl commented 5 months ago

I saw on this issue that the extension looks all the way up from the current folder, buit in my case it is in a way down, so it would need to be informed as a configuration. Could I contribute in this? Or is it already done?

firsttris commented 5 months ago

https://github.com/firsttris/vscode-jest-runner?tab=readme-ov-file#extension-settings

there is a extension setting for this jestrunner.configPath

cesar-rl commented 5 months ago

Thanks, it did the job. Now I have a problem with the reporter, I'll search for any issues about the subject.