'Intellisense for Jest not working in VS code
Solution 1:[1]
Add to your jsconfig.json
:
{
"typeAcquisition": {
"include": [
"jest"
]
}
}
If this do not work try with this command:
npm install @types/jest
or
yarn add -D @types/jest
Solution 2:[2]
Just install @types/jest
via this command:
npm i @types/jest --save-dev
Solution 3:[3]
{
"typeAcquisition": {
"include": [
"jest"
]
}
}
for those who have no luck adding above to jsconfig.json
in the root folder: try adding it to tests folder (the folder containing *.test.js
files)
Solution 4:[4]
Non of the solution works for me. After diving into some github repos in which I found it working, I found a file called jest.config.js
. Following are the configs of the file:
module.exports = {
transform: {
'^.+\\.ts?$': 'ts-jest',
},
testEnvironment: 'node',
testRegex: './src/.*\\.(test|spec)?\\.(ts|ts)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
roots: ['<rootDir>/src'],
};
Note: This is for ts
. Change all the ts
with js
if you are not using typescript.
After saving, Restart Vscode and it will work as expected.
Solution 5:[5]
This won't be for everyone but if the codebase has multiple packages in a monorepo arrangement and you use vscode as your editor, you might want to install @types/jest
in the root, rather in individually.
Solution 6:[6]
Where you call it makes a difference. Sometimes intellisense doesn't work when you are in a bad function or code block.
So if you try:
beforeEach(() => ({
mockedUseAccount.
}));
Intellisense doesn't work.
If you try:
beforeEach(() => {
mockedUseAccount.
});
Intellisense works fine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | DeltaCap019 |
Solution 2 | |
Solution 3 | solmans |
Solution 4 | Noobish |
Solution 5 | mykeels |
Solution 6 | user3294960 |