vscode-jest
vscode-jest copied to clipboard
jest.disabledWorkspaceFolders not working
Environment
-
node -v
: v10.16.2 -
npm -v
: 6.10.3 -
npm ls jest
ornpm ls react-scripts
(if you havenβt ejected): [email protected] -
your vscode-jest settings if customized:
-
Operating system: Win 10
Prerequisite
- are you able to run jest test from the command line? yes
- how do you run your tests from the command line? (for example:
npm run test
ornode_modules/.bin/jest
) npm run test
Steps to Reproduce
- add
"jest.disabledWorkspaceFolders": [ ".history" ],
to your settings. - install the VS-Code Extension Local History
- Edit some test, so that the history extension will create a copy of the test file(with the path) in the /.history/ folder (of your root).
- check if a test file is in that folder
- run tests
- See that the Test from the history folder will also be run.
Expected Behavior
I expected the test from the .history folder not to be executed, as I put the folder name in the jest.disabledWorkspaceFolders setting.
Actual Behavior
The tests in the folders will be executed every time with the others.
This problem has nothing to do with the other extension, as I could have created the folder and files my self for whatever purpose. I just did name it here to show that this is not an unusual scenario.
I believe vscode-jest auto-inserts the "jest.disabledWorkspaceFolders" settings into the wrong place when you click on the UI to insert it. I had to put it in my workspace settings and specifically put it inside the "settings" key/object, so in your case it'd look something like:
{
"settings": {
"jest.disabledWorkspaceFolders": [
".history"
],
}
}
I can confirm this also what EmpireJones suggested worked for me as well.
Strangly it did not work for me.
It's Happening here.
Jest should runs only in store
dir, but it runs in design
and docs
also.
I am using a monorepo workspace, this is the json of the workspace settings:
.vscode/workspace.code-workspace
{
"folders": [
{
"name": "β¨ foo",
"path": ".."
},
{
"name": "π¦ @foo/design",
"path": "../packages/design"
},
{
"name": "π¦ @foo/docs",
"path": "../packages/docs"
},
{
"name": "π¦ @foo/store",
"path": "../packages/store"
}
],
"settings": {
"jest.disabledWorkspaceFolders": [
"../packages/docs",
"../packages/design"
]
}
}
I tried variations of disabledWorkspaceFolders
like packages/docs
, /packages/docs
and @foo/docs
. None of them worked.
I found a workaround:
add a folder setting that disables jest automatic run on each folder of the multi-root workspace:
packages/{docs,design}/settings.json
{
"jest.autoEnable": false
}
Try using the folder name
instead of path
in disabledWorkspaceFolders
.
it worked for me when I used exactly the same name as defined in folders
as mentioned by @patspam
{
"folders": [
{
"name": "β¨ root",
"path": "."
},
{
"name": "π¦ admin-tools",
"path": "packages\\admin-tools"
},
{
"name": "π¦ @foo/functions",
"path": "packages\\functions"
},
{
"name": "π¦ @foo/types",
"path": "packages\\types"
},
{
"name": "π @foo/web",
"path": "packages\\web"
}
],
"settings": {
"jest.disabledWorkspaceFolders": [
"β¨ root",
"π¦ admin-tools",
"π¦ @foo/types"
]
}
}