vscode-jest: VSCode Intellisense is not suggesting available methods in JEST
Environment
-
node -v
: v.9.2.0 -
npm -v
: 5.5.1 -
npm ls jest
ornpm ls react-scripts
(if you haven’t ejected): npm ls jest ±- jest@24.5.0-- react-scripts@2.1.8
– jest@23.6.0 -
your vscode-jest settings if customized:
- jest.pathToJest? [fill]
- jest.pathToConfig? [fill]
- anything else that you think might be relevant? [fill]
-
Operating system: Windows_NT x64 10.0.17134
Prerequisite
- are you able to run jest test from command line? yes
- how do you run your tests from command line? npm run test
Steps to Reproduce:
Create a new react app using
1 .npx create-react-app my-app 2. npm install --save-dev jest 3. Opened the project in VSCode.
Expected Behavior
I expect VS Code intellisense would assist me with available methods from JEST.
Actual Behavior
VS Code is not suggesting me any method suggestions for JEST test cases.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 30
- Comments: 28
Links to this issue
Commits related to this issue
- Install @types/jest According to https://github.com/jest-community/vscode-jest/issues/440#issuecomment-483872233 installing @types/jest fixes Jest autocompletion. That was the case for me. — committed to olavfosse/fullstackopen-2020-blog-list by olavfosse 4 years ago
- [BURGER] Installed @types/jest to get intellisense https://github.com/jest-community/vscode-jest/issues/440#issuecomment-483872233 — committed to lesiak/react-udemy-maximilian-schwarzmuller by lesiak 4 years ago
- [BURGER] Installed @types/jest to get intellisense https://github.com/jest-community/vscode-jest/issues/440#issuecomment-483872233 — committed to lesiak/react-udemy-maximilian-schwarzmuller by lesiak 4 years ago
- [BURGER] Installed @types/jest to get intellisense https://github.com/jest-community/vscode-jest/issues/440#issuecomment-483872233 — committed to lesiak/react-udemy-maximilian-schwarzmuller by lesiak 4 years ago
- [BURGER] Installed @types/jest to get intellisense https://github.com/jest-community/vscode-jest/issues/440#issuecomment-483872233 — committed to lesiak/react-udemy-maximilian-schwarzmuller by lesiak 4 years ago
- [BURGER] Installed @types/jest to get intellisense https://github.com/jest-community/vscode-jest/issues/440#issuecomment-483872233 — committed to lesiak/react-udemy-maximilian-schwarzmuller by lesiak 4 years ago
I’m having the same problem. I’ve tried installing @types/jest with
npm i @types/jest
and the suggestions started to show again.create
jsconfig.json
in the root directory of your project. the file should contain the following:{ "typeAcquisition": { "include": [ "jest" ] } }
after saving reload vscode. Worked for me.
I found that I need to restart vscode after installing @types/jest if vscode was open during installation. Can anyone confirm if that is expected?
mine only works after i install
@types/jest
as suggestednode v10.15.0 npm v6.5.0
P.S Doing both steps worked for me, and the last one 🙂
npm i -D @types/jest
jsconfig.json
to root folder asInstall
@types/jest
as a dev dependencie works for me. I’ve tried to install it globally but it seems not work.None of the provided solutions works for me. Guess what else can I try
For some reason this solution doesn’t work for me. Interesting is that I found a post from Nicholas Zakas post with the solution you are proposing. I’m wondering if I need to tell vscode about
jsconfig.json
or doesn vscode just picked it up if its there.Including the test folder in tsconfig fixed it for me.
... "include": ["src", "test"]
My case was opening VSCode at the root of our repo, rather than the src folder which contained our jest.config.js and tsconfig.json files. When I opened the src folder as a VSCode Project, everything worked as expected.
In my vscode this solution works very well.
Installing @types/jest solved the problem while adding this to jsconfig.js could not help
{ "typeAcquisition": { "include": ["jest"] } }
This worked for me too. I have the orta.vscode-jest extension installed and am running a react 16 project with
npx create-react-app
. No restart of VSCode requiredinstall local and global types, works fine npm i @types/jest npm i -g @types/jest
Thanks, Guys, as mentioned above just the below in jsconfig.json works for me. I thought in javascript projects this is a better option, as javascript project like ReactJS does not need to install @types/xxxx. I guess @types are only for typescript projects?
Another workaround is to use explicit import: "However, if you prefer explicit imports, you can do import {describe, expect, test} from ‘@jest/globals’."as documented here https://jestjs.io/docs/api
PS: I was not able to solve the problem with other suggest methods.
Try to create a new user in your computer with a fresh installation of vscode and do
npm i -D @types/jest
and see if that works. I’m just trying to isolate all other extensions that might be causing conflict.