Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension does not activate automatically when jest.rootPath setting is used #897

Closed
mjs510 opened this issue Aug 19, 2022 · 5 comments · Fixed by #907
Closed

Extension does not activate automatically when jest.rootPath setting is used #897

mjs510 opened this issue Aug 19, 2022 · 5 comments · Fixed by #907

Comments

@mjs510
Copy link

mjs510 commented Aug 19, 2022

I have a workspace containing a tests/ sub-folder. This folder is the root for my tests, and contains its own package.json, node_modules etc. The root of my workspace is not a node project.

Reading, https://github.com/jest-community/vscode-jest/blob/master/README.md#i-dont-see-jest-in-the-bottom-status-bar I would expect that setting jest.rootPath to tests in this workspace would cause the extension to activate automatically, but this is not the case. The extension does activate successfully if I run "Jest: Start All Runners" via command palette.

Environment

  1. vscode-jest version: 4.6.0
  2. node -v: 14.2.0
  3. npm -v or yarn --version: 6.14.7
  4. npm ls jest or npm ls react-scripts (if you haven’t ejected): /path/to/workspace-root/tests
  5. your vscode-jest settings if customized:
    • jest.rootPath tests
  6. Operating system: Debian 11

Prerequisite

  • are you able to run jest test from the command line? Yes
  • how do you run your tests from the command line? node_modules/.bin/jest

Steps to Reproduce

Expected Behavior

/tmp/vscode-jest-root-path/.vscode/settings.json sets jest.rootPath to tests so I would expect the jest extension to activate when I launch code in this folder.

Actual Behavior

The extension does not activate automatically, but does activate successfully if I run "Jest: Start All Runners" via command palette.

@ManfredLange
Copy link

ManfredLange commented Sep 5, 2022

Looks as if this extension has problems if the directory structure is just a little bit different to what might be the "standard".

For example: We don't have package.json at the root of the repository. Instead we have a directory service within which we have the package.json file as well as jest.config.json. From the command line and without this extension jest (not the extension) appears to work as expected.

Getting this extension to work correctly, is a big challenge. For example, while using "Jest: Start All Runners" from the command palette appears to do something, it does not find tests. jest-cli finds the tests, though, and executes them.

Note: We are using dev containers so the location of this extension in the container seems to be /home/node/.vscode-server/extensions/orta.vscode-jest-4.6.0.

@connectdotz
Copy link
Collaborator

@mjs510 you are right. The current auto-activation is "shallow", i.e. it only check the root folder. I am planning to change that in the next release. Thanks for the reminder.

@ManfredLange if it worked when you open the "service" folder as root, then you can do what @njs510 did by setting the jest.rootPath to your service directory. While you will need to manually activate the extension (by issuing the command as you already discovered) until the next release, nevertheless the extension should work with your folder structure. If you still have problems, feel free to let us know.

@connectdotz
Copy link
Collaborator

this issue should be fixed in v5 pre-release, feel free to give it a spin and let us know how it works for you. Thanks.

@marcellino-ornelas
Copy link

I was facing same issue, switched to pre release version and vscode-jest automatically spins up now 👏 🙇‍♂️

@chidam02
Copy link

chidam02 commented May 22, 2024

I am facing the same issue now in version 6.2.5. I am using submodules.
The folder structure would look like -

 .vscode
       directory1
               submodules
                         root-project-dir-of-node

in .vscode's settings I have configured rootpath:directory1/submodules/root-project-of-node and configured jest command line

while opening code extension is not activated automatically need help in setting up vs code multi root or multi folders configuration

please post links or references to follow .

thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants