VS Code中Jest的IntelliSense提示缺失?Mac端失效Windows正常求排查
Hey there, I’ve had several colleagues and seen plenty of forum threads about this exact problem—Jest IntelliSense working fine on Windows VS Code but suddenly dropping out on Mac, even though it used to work perfectly. Let’s go through the fixes that usually get it back up and running, plus confirm you’re not alone here!
1. First, Verify Your Extension & Workspace Setup
- Double-check that the official Jest extension (or whichever Jest tooling extension you rely on) is still enabled. VS Code updates sometimes disable extensions unexpectedly, so head to the Extensions tab, search for Jest, and make sure it’s toggled on.
- Pop open your workspace
settings.json(hitCmd+Shift+Pthen search "Open Workspace Settings (JSON)") and make sure you have these configs set (adjust as needed for your project):
This tells VS Code exactly where to find your Jest setup."jest.jestCommandLine": "npx jest", // Or use your package.json script like "npm test" "jest.rootPath": "${workspaceFolder}", "typescript.tsdk": "node_modules/typescript/lib"
2. Clear VS Code’s Cache (Mac-Specific Fix)
Mac VS Code has a habit of holding onto corrupted cache files that break IntelliSense. Here’s how to wipe them:
- Quit VS Code entirely (don’t just close the window—use
Cmd+Qor quit from the menu bar) - Open Terminal and run these commands to delete the cache directories:
rm -rf ~/Library/Caches/Code rm -rf ~/Library/Application\ Support/Code/CachedData - Restart VS Code and load your project again. More often than not, this fixes the missing hints issue.
3. Ensure Type Definitions Are Installed (For TypeScript Users)
If you’re working with TypeScript, missing @types/jest is a common culprit. Install it with:
npm install --save-dev @types/jest # Or if you use yarn: yarn add -D @types/jest
Then add "jest" to the types array in your tsconfig.json:
{ "compilerOptions": { "types": ["jest", "node"] // Include other types you need here } }
This lets TypeScript recognize Jest’s global methods like test() and expect().
4. You’re Definitely Not Alone!
This is a super common post-update issue on Mac. I’ve seen dozens of users report that after a VS Code or Jest extension update, IntelliSense stops working until they clear the cache or recheck their extension settings. Some folks also fixed it by switching the Jest extension’s "Run Mode" from on-demand to watch (you can find this in the extension’s settings).
内容的提问来源于stack exchange,提问作者Lukasz 'Severiaan' Grela

