Vscode-jest: No standard JS/TS autocompletion in Jest test files

Created on 16 Apr 2019  路  6Comments  路  Source: jest-community/vscode-jest

Environment

  1. node -v: v10.15.3
  2. npm -v: 6.9.0
  3. npm ls jest or npm ls react-scripts (if you haven鈥檛 ejected): 24.7.1

  4. Operating system: Windows 10 Pro

Prerequisite

  • are you able to run jest test from command line? Yes
  • how do you run your tests from command line? (for example: npm run test or node_modules/.bin/jest) jest, npm run test

I'm checking out VSCode, as a possible replacement for WebStorm/IntelliJ (they're both great - just interested in knowing how to use both), so please bare with me if I've missed something obvious, such as a configuration setting.

This is a "pretty much" fresh VSCode install. I've not tweaked settings outside of installing standard extensions (eslint, test runners, etc), and setting up some keybindings.

Steps to Reproduce

This happens in this repo.

The summary is that if I open a test file in VSCode, it doesn't seem to get treated completely as a JS/TS file; in particular, it doesn't have the same level of autocompletion I get when using JS/TS files.

Note in the first screenshot the file is set to "Javascript", and VSCode not only provides autocompletion, it flags the code after the throw as unreachable.

ss+(2019-04-16+at+12 56 19)

Now note how in the second screenshot, with the file set to "
ss+(2019-04-16+at+12 56 47)


I'm trying to tackle these things one issue at a time, but I've also run into a couple of other problems with this extension so far:

  • Where do I actually see the output of the test runner? With the repo I linked to, I can't even run the jest tests, even if I comment out the throw - I just get a red "x", and can't find any sign out output.
  • I have no gutter icons - I'm not yet ready to report this as an issue, as I think it's likely I'm missing a vital configuration setting.

For me, the biggest difference (at least, that matters) between VSCode & IntelliJ/WebStorm is the test runner, which is what I'm hoping VSCode can match (w/ gutter icons and navigation being a big part of this).

Let me know if theses anything else I can do to help with this issue, and thanks in advance for your time :)

All 6 comments

does #78 help?

also didn't see jest message in your status bar, it didn't seem vscode-jest extension is running, can you turn on debug mode (see troubleshooting) and check...

I'm having the same trouble using react-native with javascript and typescript. I manually added yarn add @types/jest but that doesn't solve anything. One small step away from loving this plugin!

@connectdotz I'm working with TypeScript, so I have to have @types/jest installed, otherwise TS can't use jest.

it didn't seem vscode-jest extension is running

That seems to be the case, since it wasn't installed...? Installing vscode-jest solved the problem, as would be expected. Sorry about that - I guess I got my extensions mixed up.

However, I do still have the auto completion problem, and no runnable gutter icons.

I resolved my intellisense problem by nuking my code install on windows:
Uninstall vscode
Deleted code folder located at %appdata%code
Deleted .vscode folder located at %userprofile%.vscode
Reinstalled from website
Installed this plugin along with a couple of others.

At the command prompt I typed: react-native init myproj --template typescript

Then cd into myproj and type code . to open the folder in code. Created a test and voila - all is right with the world.

I resolved my intellisense problem by nuking my code install on windows:
Uninstall vscode
Deleted code folder located at %appdata%code
Deleted .vscode folder located at %userprofile%.vscode
Reinstalled from website
Installed this plugin along with a couple of others.

At the command prompt I typed: react-native init myproj --template typescript

Then cd into myproj and type code . to open the folder in code. Created a test and voila - all is right with the world.

The only method that worked for me for a nodejs library with ts-config...I have saved the config just in case and planning to reapply.

Before, even when I managed to make it search for tests it was always showing 1 runned, 1 failed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

offero picture offero  路  4Comments

RehanSaeed picture RehanSaeed  路  5Comments

radfahrer picture radfahrer  路  3Comments

FDiskas picture FDiskas  路  3Comments

DaniGTA picture DaniGTA  路  3Comments