vscode-jest
vscode-jest copied to clipboard
On Win10 Extraneous Backslashes are Present in Filenames When using "Run Test".
Environment
-
vscode-jest version
: 5.2.3 -
node -v
: v14.17.0 -
npm -v
: 7.24.2 -
npm ls jest
: [email protected] C:\git\Banana\application\bananaFolder ├─┬ [email protected] │ ├─┬ [email protected] │ │ └── [email protected] deduped │ └── [email protected] └─┬ [email protected] └─┬ [email protected] ├─┬ [email protected] │ └── [email protected] deduped └── [email protected] deduped - your vscode-jest settings if customized:
- jest.jestCommandLine? n/a
- jest.autoRun? off
- anything else that you think might be relevant? [fill]
- Operating system: Edition
Windows 10 Pro Version 22H2 Installed on 8/16/2022 OS build 19045.3448 Experience Windows Feature Experience Pack 1000.19044.1000.0
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 (test script is"test": "react-scripts test --env=jsdom"
Steps to Reproduce
When running all tests in the project with Run Test (either from menu or green play button), the command generated is:
> react-scripts test --env=jsdom "--testLocationInResults" "--json" "--useStderr"
"--outputFile" "C:\\Users\\myName\\AppData\\Local\\Temp\\jest_runner_banana_web_frontend_myname_2.json"
"--no-coverage" "--reporters" "default"
"--reporters" "c:\\Users\\MyName\\.vscode\\extensions\\orta.vscode-jest-5.2.3\\out\\reporter.js"
"--colors" "--watchAll=false"
When running a test in Debug for a single test or single file (either from the Menu or green debug button) the command generated is:
${env:NODE_OPTIONS}=' --require "c:/Users/MyName/AppData/Local/Programs/Microsoft VS Code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.js"
--inspect-publish-uid=http';
${env:VSCODE_INSPECTOR_OPTIONS}=':::{"inspectorIpc":"\\\\.\\pipe\\node-cdp.19832-57a36fbd-1.sock",
"deferredMode":false,"waitForDebugger":"",
"execPath":"C:\\nodejs\\node.exe",
"onlyEntrypoint":false,"autoAttachMode":"always",
"fileCallback":"C:\\Users\\MyName\\AppData\\Local\\Temp\\node-debug-callback-4a66926ce44c1ec6"}';
& 'C:\nodejs\npm.cmd' 'test' '--' 'test' '--env=jsdom' '--runInBand' '--watchAll=false'
'--testNamePattern' 'Permission Util'
'--runTestsByPath' 'C:\git\Banana\application\banana-web-frontend\src\test\util\permissionUtil.test.ts'
When running a Run Test for a single test or single file (either from the Menu or green play button) the command generated is:
> react-scripts test --env=jsdom "--testLocationInResults" "--json" "--useStderr"
"--outputFile" "C:\\Users\\MyName\\AppData\\Local\\Temp\\jest_runner_banana_web_frontend_myname_2.json"
"--testNamePattern" "Permission Util" "--no-coverage" "--reporters" "default"
"--reporters" "c:\\Users\\MyName\\.vscode\\extensions\\orta.vscode-jest-5.2.3\\out\\reporter.js"
"--colors" "--watchAll=false"
"--testPathPattern" "c:\\\\git\\\\Banana\\\\application\\\\banana-web-frontend\\\\src\\\\test\\\\util\\\\permissionUtil\\.test\\.ts"
Note the file name has extraneous backslashes inside the name of the file and all the backslashes are escaped unlike the paths in the Debug mode (which works as expected).
Relevant Debug Info
Here is the output:
No tests found, exiting with code 1 Run with
--passWithNoTests
to exit with code 0 In C:\git\Banana\application\banana-web-frontend 719 files checked. testMatch: C:/git/Banana/application/banana-web-frontend/src//tests//.{js,jsx,ts,tsx}, C:/git/Banana/application/banana-web-frontend/src/**/.{spec,test}.{js,jsx,ts,tsx} - 303 matches testPathIgnorePatterns: \node_modules\ - 719 matches testRegex: - 0 matches Pattern: c:\\git\\Banana\\application\\banana-web-frontend\\src\\test\\util\\permissionUtil\.test\.ts - 0 matches
Expected Behavior
Test is found and runs.
Actual Behavior
see above
The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself. If you are interested, feel free to check out the contribution guide, we look forward to seeing your PR...
noticed you are using npm 7.x, which had issue with pass-through argument interpretation, see comment. Can you try with npm >= 8.15?