Vscode-jest: Autocompletion / intellisense

Created on 9 Feb 2017  路  12Comments  路  Source: jest-community/vscode-jest

Hi there,

First, great extension. Very helpful.

I noticed in your gif that you have autocomplete working for Jest (expect), is that something that this extension adds? Or do you have something else set up to enable that?

Thanks!

Most helpful comment

Ah yeah, that comes from having yarn add @types/jest in the project

I have also wondered about making this something that the extension provides, not sure though, perhaps it could add a one-time-per-project popover saying "maybe you want @types/jest?" ?

All 12 comments

I notice this as well. Mine doesn't show autocomplete for expect neither with the extension installed.

Ah yeah, that comes from having yarn add @types/jest in the project

I have also wondered about making this something that the extension provides, not sure though, perhaps it could add a one-time-per-project popover saying "maybe you want @types/jest?" ?

How can we fix this locally?

It's a symptom of using TypeScript specifically. However if you do yarn add @types/jest like orta mentioned and also setup a tsconfig.json file I believe it can be made to work in *.js files as well.

I thought the TS engine in VSCode was meant to auto-download types? But installing the types fixed the problem, without a tsconfig.json.

Thanks for the help!

It would be nice if the extension did provide autocompletion, I think. For example, by adding or simulating a jsconfig.json with

{ "typeAcquisition": { "include": ["jest"] } }

Hi, is it still required to install yarn add @types/jest to get autocomplete for jest's expect?

Do I need to add a jsconfig.json as well, @spacecakes (also referenced here: https://github.com/facebook/create-react-app/issues/3005)?

Can we have autocomplete without installing @types/jest?

Not from this extension, it'll probably end up in a future build of jest now that it's all typescript

Just added intellisense to my expectations woohoo! Yeah thanks all, the link to the create-react-app issue confirmed spacecakes [with correct opening bracket ;) ].
All it took was saving a jsconfig.json file in root folder of project with the following and it started working.

{
    "typeAcquisition": {
        "include": [
            "jest"
        ]
    }
}

As it happened I didn't have yarn and generally prefer to minimise my projects dependencies. It also feels more right that I just need my projects js requirements defined rather than reaching out to typescript in a non-TS project. Fair enough that jest uses it, but that shouldn't be my projects concern.

woot, thanks for intellisense! I also only had to add the config @tyeth referenced. :) (i'm using a non-ejected cra)

Ah yeah, that comes from having yarn add @types/jest in the project

I have also wondered about making this something that the extension provides, not sure though, perhaps it could add a one-time-per-project popover saying "maybe you want @types/jest?" ?

that worked.. but maybe it would better to install it as a dev dependency yarn add --dev @types/jest

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luisrudge picture luisrudge  路  27Comments

connectdotz picture connectdotz  路  24Comments

therazor picture therazor  路  36Comments

karb0f0s picture karb0f0s  路  37Comments

Glutnix picture Glutnix  路  37Comments