jest-community / vscode-jest

The optimal flow for Jest based testing in VS Code
MIT License
2.84k stars 294 forks source link

Error loading new preview extension #1099

Closed jpierson-at-riis closed 10 months ago

jpierson-at-riis commented 11 months ago

Environment

  1. vscode-jest version: v6.1.0 pre-release
  2. node -v: v18.12.0
  3. npm -v or yarn --version: 8.19.2
  4. npm ls jest or npm ls react-scripts (if you haven’t ejected):
    online-application-frontend@0.1.0 C:\projects\online-application-frontend
    ├─┬ @storybook/preset-create-react-app@7.0.18
    │ └── react-scripts@5.0.1 deduped
    └── react-scripts@5.0.1
  5. your vscode-jest settings if customized:
    • jest.jestCommandLine? default
    • jest.autoRun? default
    • anything else that you think might be relevant? I was also having issues with the release version of the extension. I tried uninstalling and reinstalling a few times but it didn't seem to help. I was getting a Windows dialog window with an error each time I tried using the extension through the command pallet. The extension has otherwise been working just fine for months.
  6. Operating system: Microsoft Windows 10 Enterprise 10.0.19044 N/A Build 19044

Prerequisite

Steps to Reproduce

  1. Install the extension
  2. Restart VSCode

Relevant Debug Info

[fill]

Expected Behavior

The extension should load, the beaker icon should show in the left tab menu, and the extension should be available and effective in the editor.

Actual Behavior

The extension does not load, the beaker icon does not show in the left tab menu, and the extension does not appear to be effective in the editor. The following error shows up when starting up the editor after installing the extension.

Failed to activate extension for "my-project": TypeError: Cannot read properties of undefined (reading 'length')

Output (adjusted for privacy) for window in VSCode:

023-12-12 23:31:35.244 [warning] Settings pattern "GitHub.copilot.manageExtension" doesn't match any settings
2023-12-12 23:31:36.040 [warning] Settings pattern "application.*" doesn't match any settings
2023-12-12 23:31:36.472 [error] [Extension Host] Failed to activate extension for "project-name": TypeError: Cannot read properties of undefined (reading 'length')
    at t.RunShell.initFromSetting (c:\Users\myusername\.vscode\extensions\orta.vscode-jest-6.1.0\out\extension.js:2:398907)
    at new t.RunShell (c:\Users\myusername\.vscode\extensions\orta.vscode-jest-6.1.0\out\extension.js:2:398757)
    at t.getExtensionResourceSettings (c:\Users\myusername\.vscode\extensions\orta.vscode-jest-6.1.0\out\extension.js:2:377891)
    at t.JestExt.getExtensionResourceSettings (c:\Users\myusername\.vscode\extensions\orta.vscode-jest-6.1.0\out\extension.js:2:363351)
    at new t.JestExt (c:\Users\myusername\.vscode\extensions\orta.vscode-jest-6.1.0\out\extension.js:2:362215)
    at t.ExtensionManager.addExtension (c:\Users\myusername\.vscode\extensions\orta.vscode-jest-6.1.0\out\extension.js:2:442681)
    at c:\Users\myusername\.vscode\extensions\orta.vscode-jest-6.1.0\out\extension.js:2:442541
    at Array.forEach (<anonymous>)
    at t.ExtensionManager.applySettings (c:\Users\myusername\.vscode\extensions\orta.vscode-jest-6.1.0\out\extension.js:2:442524)
    at new t.ExtensionManager (c:\Users\myusername\.vscode\extensions\orta.vscode-jest-6.1.0\out\extension.js:2:441819)
    at e.activate (c:\Users\myusername\.vscode\extensions\orta.vscode-jest-6.1.0\out\extension.js:2:1337163)
    at W.ib (c:\Users\myusername\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:154:13237)
    at W.hb (c:\Users\myusername\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:154:12951)
    at c:\Users\myusername\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:154:11080
    at async u.n (c:\Users\myusername\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6255)
    at async u.m (c:\Users\myusername\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:6218)
    at async u.l (c:\Users\myusername\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:140:5675)
2023-12-12 23:31:38.049 [warning] Settings pattern "application.*" doesn't match any settings
2023-12-12 23:31:40.140 [warning] Settings pattern "application.*" doesn't match any settings
connectdotz commented 11 months ago

Hi, did you happen to have a jest.shell setting? The stack trace seems to imply a possible incomplete jest.shell setting that is missing the "args" property, which could trigger this error.

I will patch it to make it more fault-tolerant. Meanwhile, you can just add an empty array, such as:

"jest.shell": { 
    "path": "/bin/zsh", 
    "args": [] 
}
jpierson-at-riis commented 10 months ago

Thanks, I'll check my jest.shell setting.

jpierson-at-riis commented 10 months ago

Ok, so I think the jest.shell setting and perhaps some other things may have been related to why the problem was happening for me.

  1. I had some commented out lines in my user level settings.json file for Windows that I believe may have been causing some tools such as prettier to choke when trying to modify the file and may have also caused incorrect configuration as well. Removing these seemed to have some positive impact but I haven't tried the project on the Windows side yet to verify.
  2. My user setting had some windows specific paths to powershell which don't apply in WSL where I've been trying to get the project running lately to avoid several other unrelated problems with corporate bloatware interfering with development tools. Simply creating a WSL specific settings.json file through VSCode and then overriding the jest.shell property as shown below allowed the extension to load when VSCode is launched through WSL.

    {
    "jest.shell": ""
    }

There may be some remaining tinkering necessary but it looks like I have the basic features now working and I can begin to once again iterate on the https://github.com/jest-community/vscode-jest/issues/1022 issue getting the debugger to launch.