Run Jest inside sub-folder
See original GitHub issueI’m getting this error when trying to watch jest:
command 'extension.jest.startJest' not found
So, after I installed the extension, nothing happens:
Issue Analytics
- State:
- Created 7 years ago
- Comments:27 (14 by maintainers)
Top Results From Across the Web
Run Jest tests only for current folder - Stack Overflow
For e.g. if I go to c:/dev/app in terminal and type some-jest-command , it should only run files with .test.js present in the...
Read more >How to run tests only from a specific directory in Jest? Define ...
How to run tests only from a specific directory in Jest? Define your test files pattern with KNAPSACK_PRO_TEST_FILE_PATTERN. You can modify a default...
Read more >Configuring Jest
When the projects configuration is provided with an array of paths or glob patterns, Jest will run tests in all of the specified...
Read more >Running Tests in Subdirectories - Laracasts
Running Tests in Subdirectories. I would like to organize my tests using subdirectories rather than just all in the root ./tests directory.
Read more >[Solved]-Jest takes more time if jest.config.js is in subfolder or ...
Coding example for the question Jest takes more time if jest.config.js is in subfolder or subdirectory-Vue.js.
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
Also having that problem. Jest Debug Console says:
Took me a while, but I finally figured it out:
Final solution
runJest.sh
file (in workspace root)cd relative/path/to/project && npm test # NOTE: path contains
package.jsonand have a
testscript defined
settings.json
, add:"jest.pathToJest": "sh runJest.sh"
Making the Debugger work as well
When pressing “Debug” next to a test, things still error out, so what to do?
As they point out in “How to I debug tests?”, you need to add a custom test runner config in
launch.json
which MUST containname: "vscode-jest-tests"
. I added this (and it works!!):(NOTE: This even works on Windows if you have Cygwin installed and properly configured)
Problem Solving Process
jest.pathToJest
setting, however there is no documentation on how its supposed to work.npm test --
, realizing it’s actually ill-named: it’s a command-line/shell command and not a path.jest
from the error message (spawn jest ENOENT
) refers to the value ofpathToJest
."jest.pathToJest": "cd projects/todomvc/examples/vanilla-es6/ && npm test"
.${workspaceFolder}
) won’t be recognized (at least it did not when I tried, might just be a temporary bug)After the last update, still not working for me. 😦