From 301fd86e4f24d316de1edb78378f9ca36805df14 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Mon, 15 Apr 2024 16:40:38 -0300 Subject: [PATCH] fix: VSCode Jest debugging (#28388) --- .vscode/launch.json | 31 +++++++++++++++++++++++-------- .vscode/settings.json | 9 +++++++-- package.json | 2 -- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0e883005baee3b..998732a9141ace 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -31,7 +31,7 @@ "request": "launch", "name": "Jest Current File", "runtimeExecutable": "pnpm", - "program": "jest:vscode", + "program": "jest", "args": [ "--runInBand", "--collectCoverage=false", @@ -52,7 +52,7 @@ "request": "launch", "name": "Jest All", "runtimeExecutable": "pnpm", - "program": "jest:vscode", + "program": "jest", "args": [ "--runInBand", "--collectCoverage=false", @@ -71,7 +71,7 @@ "request": "launch", "name": "Jest Current Folder", "runtimeExecutable": "pnpm", - "program": "jest:vscode", + "program": "jest", "args": [ "--runInBand", "--collectCoverage=false", @@ -84,14 +84,29 @@ }, { "type": "node", - "name": "vscode-jest-tests", + "name": "vscode-jest-tests.v2", "request": "launch", "console": "integratedTerminal", - "internalConsoleOptions": "neverOpen", + "internalConsoleOptions": "openOnSessionStart", "cwd": "${workspaceFolder}", - "runtimeExecutable": "pnpm", - "program": "jest:vscode", - "args": ["--runInBand", "--watchAll=false", "--testTimeout=100000000"] + "runtimeExecutable": "node", + "runtimeArgs": ["--experimental-vm-modules"], + "program": "node_modules/jest/bin/jest.js", + "args": [ + "--runInBand", + "--watchAll=false", + "--testTimeout=100000000", + "--coverage=false", + "--runTestsByPath", + "${jest.testFile}", + "--testNamePattern", + "${jest.testNamePattern}" + ], + "env": { + "NODE_ENV": "test", + "LOG_LEVEL": "trace", + "GIT_ALLOW_PROTOCOL": "file" + } } ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 9e9e9e57616939..9a5cba35c8c111 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,8 +16,13 @@ ".releaserc": "json" }, "omnisharp.autoStart": false, - "jest.autoRun": "off", - "jest.jestCommandLine": "pnpm jest", + "jest.runMode": "on-demand", + "jest.jestCommandLine": "node --experimental-vm-modules node_modules/jest/bin/jest.js", + "jest.nodeEnv": { + "NODE_ENV": "test", + "LOG_LEVEL": "trace", + "GIT_ALLOW_PROTOCOL": "file" + }, "npm.packageManager": "pnpm", "editor.formatOnSave": true, "editor.codeActionsOnSave": { diff --git a/package.json b/package.json index bc3f15fb8bcefb..e5bf651606ee3a 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,6 @@ "generate:imports": "node tools/generate-imports.mjs", "git-check": "node tools/check-git-version.mjs", "jest": "node tools/jest.mjs", - "jest:vscode": "node tools/jest.mjs", - "jest-debug": "NODE_OPTIONS='$NODE_OPTIONS --inspect-brk' node tools/jest.mjs --testTimeout=100000000", "lint": "run-s ls-lint type-check eslint prettier markdown-lint git-check doc-fence-check", "lint-fix": "run-s eslint-fix prettier-fix markdown-lint-fix", "ls-lint": "ls-lint",