Auto-detect project path?
See original GitHub issueI’m new to vscode and this extension, so I’m not sure if I’m missing something.
My workspace contains a Java backend and a TypeScript/JavaScript frontend. The frontend is in folder scroll-documents-ui/src/main/frontend
. Getting this extension to work wasn’t easy, as it was not clear from the documentation which config option I would have to set:
- Without any config, it wouldn’t work as it would look for jest in
node_modules/.bin/jest
based on my workspace directory, rather than the frontend directory. - Specifying
jestrunner.jestPath
didn’t work, because it was running the tests from the workspace directory, rather than the frontend directory. For some reason this caused jest not to be able to parse the test files. Also, a relative path worked forjestrunner.jestPath
despite the documentation specifying that it needs to be an absolute path. - Specifying
jestrunner.projectPath
worked, although only as an absolute path, not as a relative path.
The main pain points that I see here are:
- The documentation is not very explicit on how exactly to configure a multi-module workspace, even though I think that scenario is very common when developing an application that has a frontend and a backend?
- The requirement of specifying
jestrunner.projectPath
as an absolute path makes it impossible to share my workspace config with other developers. - What if I want to use jest in multiple modules, for example in the frontend and in the backend?
I’m wondering why this extension is not detecting the project path automatically? My guess would be that it should be the closest ancestor directory to the test for which a node_modules/.bin/jest
sub-path exists.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Multi-root Workspaces in Visual Studio Code
You can open and work on multiple project folders in Visual Studio Code with multi-root ... a "workspace" is just your project's single...
Read more >virtualenvwrapper: how to update project path? - Stack Overflow
According to the docs you can use setvirtualenvproject . This will automatically move you to the project folder if you use the workon...
Read more >Unable to autodetect 'javac' path, using 'javac' from the ...
Hello, I'm experiencing this error when trying to build a specific maven project: "Unable to autodetect 'javac' path, using 'javac'...
Read more >Toolchains for JVM projects - Gradle User Manual
Additionally, you may want to build a project using a Java version that is not ... Any tasks that can be configured with...
Read more >build_ios_app - fastlane docs
Sensible defaults: Automatically detect the project, its schemes and more ... build") # store the ipa in this folder output_name("MyApp") # the name...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone who’s interested, here’s a simple shell script which I use for a Yarn workspaces project:
How to use
"jestrunner.jestCommand": ". bin/jest.sh"
to your VSCodesettings.json
This script is my opinionated way to auto-detect the working directory of the test file. It can be improved to be more “smart” about how to find the CWD (e.g. traverse the file tree looking for a package.json,…)
Hey guys, for me and many others the extension already works well with yarn workspaces.
the only thing which is not currently supported is if your jest binrary / config is not in the root folder.
i think the smartest way to solve this would be a todo a reverse lookup for the jest binrary. To find the hierarchy level where the jest binrary is in the node_modules. This should be the correct folder to start Jest.