vscode-jest icon indicating copy to clipboard operation
vscode-jest copied to clipboard

jest.disabledWorkspaceFolders not working

Open garyee opened this issue 4 years ago β€’ 7 comments

Environment

  1. node -v: v10.16.2

  2. npm -v: 6.10.3

  3. npm ls jest or npm ls react-scripts (if you haven’t ejected): [email protected]

  4. your vscode-jest settings if customized:

  5. 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 or node_modules/.bin/jest) npm run test

Steps to Reproduce

  1. add "jest.disabledWorkspaceFolders": [ ".history" ], to your settings.
  2. install the VS-Code Extension Local History
  3. 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).
  4. check if a test file is in that folder
  5. run tests
  6. 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.

garyee avatar May 13 '20 11:05 garyee

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"
		],
	}
}

EmpireJones avatar May 20 '20 00:05 EmpireJones

I can confirm this also what EmpireJones suggested worked for me as well.

jd1378 avatar May 22 '20 02:05 jd1378

Strangly it did not work for me.

garyee avatar May 27 '20 13:05 garyee

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.

klarkc avatar Sep 22 '20 14:09 klarkc

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
}

klarkc avatar Sep 22 '20 15:09 klarkc

Try using the folder name instead of path in disabledWorkspaceFolders.

patspam avatar Aug 29 '21 21:08 patspam

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"
    ]
  }
}

dracomithril avatar Sep 19 '21 11:09 dracomithril