jest-community / vscode-jest

The optimal flow for Jest based testing in VS Code
MIT License
2.83k stars 290 forks source link

No standard JS/TS autocompletion in Jest test files #445

Open G-Rath opened 5 years ago

G-Rath commented 5 years ago

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’t ejected): 24.7.1

  4. Operating system: Windows 10 Pro

Prerequisite

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:

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 :)

connectdotz commented 5 years ago

does #78 help?

connectdotz commented 5 years ago

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...

BluejacketScott commented 5 years ago

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!

G-Rath commented 5 years ago

@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.

BluejacketScott commented 5 years ago

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.

taosx commented 4 years ago

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.