Process failed: spawn C:\WINDOWS\system32\cmd.exe ENOENT Jest process "watch-tests" ended unexpectedly with wsl 2 and jest extension

Viewed 1159

I'm running vscode in wsl2 with the orta.vscode-jest extension. The extension would work fine when I opened vscode through powershell, but when I run vscode through wsl2 I get the following error:

VSCode jest notification error

I also get the following error

not-test onProcessExit: process exit with code=4294963238, signal=undefined
 see troubleshooting: https://github.com/jest-community/vscode-jest/blob/master/README.md#troubleshooting
'\\wsl.localhost\Ubuntu\home\{mypath}\wwwroot'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Windows\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Windows\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2021-09-13T16_50_21_922Z-debug.log
Jest process "watch-tests" ended unexpectedly
 see troubleshooting: https://github.com/jest-community/vscode-jest/blob/master/README.md#troubleshooting

It's running within a React app with these jest settings in package.json

 "jest": {
    "coverageReporters": [
      "lcov",
      "text"
    ],
    "coveragePathIgnorePatterns": [
      "src/index.tsx",
      "src/locales/"
    ],
    "coverageThreshold": {
      "global": {
        "branches": 84,
        "functions": 85,
        "lines": 85,
        "statements": 85
      }
    }
  }

I can run my coverage from the cli using "npm run coverage" where the coverage script is defined as follows:

react-scripts test --coverage --resetMocks=false

But I'd like the watch functionality to work.

Any help would be appreciated!

1 Answers

I figured out the issue was that I was launching vscode from inside powershell when I should have launched it within wsl.

Edit: Sorry, it is a bit unclear from my initial description. I'll try to elaborate. Normally, I'd open up vscode by navigating to the folder in file explorerer and select "open with code". I believe my "open with code" was not launching the wsl 2 instance even though it was in my wsl path. I fixed it by opening wsl2 in that directory and selecting "code ." I'm sure there's another way by launching a wsl 2 instance in powershell, but I haven't tried that.

Related