Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest extension doesn't seem to be running, and so does its intellisense #269

Closed
ueeieiie opened this issue Feb 21, 2018 · 9 comments
Closed

Comments

@ueeieiie
Copy link

ueeieiie commented Feb 21, 2018

Environment

  1. node -v: [8.9.4]
  2. npm -v: [5.6.0]
  3. Operating system: [Windows 10 Pro]

Steps to Reproduce

Achiving intellisense for jest commands
like in here:

Expected Behavior

getting the list of available methods from jest
and get indication that Jest extension works, by seeing the Jest icon on the status bar

Actual Behavior

  1. Getting a defaultive different menu of options
  2. No Jest icon on the status bar
    no intellisense

Logs of Developers Tools Console

I've added "jest.pathToJest": "node_modules/.bin/jest" into settings.json

When ./vscode/settings.json is open I get this in the console:

`console.ts:123 [Extension Host] [2018-02-21T23:45:22.770Z] [INFO] nuclide - Path to Flow: flow
mainThreadExtensionService.ts:43 [flowtype.flow-for-vscode]Cannot read property 'document' of undefined
e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:43
e._doInvokeHandler @ rpcProtocol.ts:174
e._invokeHandler @ rpcProtocol.ts:159
e._receiveRequest @ rpcProtocol.ts:108
e._receiveOneMessage @ rpcProtocol.ts:90
(anonymous) @ rpcProtocol.ts:33
(anonymous) @ rpcProtocol.ts:213
e.fire @ event.ts:142
(anonymous) @ ipc.net.ts:81
emitOne @ events.js:96
emit @ events.js:191
readableAddChunk @ _stream_readable.js:178
Readable.push @ _stream_readable.js:136
onread @ net.js:560
mainThreadExtensionService.ts:44 TypeError: Cannot read property 'document' of undefined
	at C:\Users\Suziz\.vscode\extensions\flowtype.flow-for-vscode-0.7.3\build\flowDiagnostics.js:351:58
	at e.fire (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:88:729)
	at e.$acceptModelChanged (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:624:197)
	at e._doInvokeHandler (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:584:983)
	at e._invokeHandler (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:584:701)
	at e._receiveRequest (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:583:836)
	at e._receiveOneMessage (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:583:605)
	at c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:582:671
	at c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:585:523
	at c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:87:459
e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:44
e._doInvokeHandler @ rpcProtocol.ts:174
e._invokeHandler @ rpcProtocol.ts:159
e._receiveRequest @ rpcProtocol.ts:108
e._receiveOneMessage @ rpcProtocol.ts:90
(anonymous) @ rpcProtocol.ts:33
(anonymous) @ rpcProtocol.ts:213
e.fire @ event.ts:142
(anonymous) @ ipc.net.ts:81
emitOne @ events.js:96
emit @ events.js:191
readableAddChunk @ _stream_readable.js:178
Readable.push @ _stream_readable.js:136
onread @ net.js:560
mainThreadExtensionService.ts:43 [flowtype.flow-for-vscode]Cannot read property 'document' of undefined
e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:43
e._doInvokeHandler @ rpcProtocol.ts:174
e._invokeHandler @ rpcProtocol.ts:159
e._receiveRequest @ rpcProtocol.ts:108
e._receiveOneMessage @ rpcProtocol.ts:90
(anonymous) @ rpcProtocol.ts:33
(anonymous) @ rpcProtocol.ts:213
e.fire @ event.ts:142
(anonymous) @ ipc.net.ts:81
emitOne @ events.js:96
emit @ events.js:191
readableAddChunk @ _stream_readable.js:178
Readable.push @ _stream_readable.js:136
onread @ net.js:560
mainThreadExtensionService.ts:44 TypeError: Cannot read property 'document' of undefined
	at C:\Users\Suziz\.vscode\extensions\flowtype.flow-for-vscode-0.7.3\build\flowDiagnostics.js:351:58
	at e.fire (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:88:729)
	at e.$acceptModelChanged (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:624:197)
	at e._doInvokeHandler (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:584:983)
	at e._invokeHandler (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:584:701)
	at e._receiveRequest (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:583:836)
	at e._receiveOneMessage (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:583:605)
	at c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:582:671
	at c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:585:523
	at c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:87:459
e.$onExtensionRuntimeError @ mainThreadExtensionService.ts:44
e._doInvokeHandler @ rpcProtocol.ts:174
e._invokeHandler @ rpcProtocol.ts:159
e._receiveRequest @ rpcProtocol.ts:108
e._receiveOneMessage @ rpcProtocol.ts:90
(anonymous) @ rpcProtocol.ts:33
(anonymous) @ rpcProtocol.ts:213
e.fire @ event.ts:142
(anonymous) @ ipc.net.ts:81
emitOne @ events.js:96
emit @ events.js:191
readableAddChunk @ _stream_readable.js:178
Readable.push @ _stream_readable.js:136
onread @ net.js:560
console.ts:123 [Extension Host] Error: Document version already has changed
	at C:\Users\Suziz\.vscode\extensions\naumovs.color-highlight-2.3.0\dist\extension.js:2903:17
	at <anonymous>
@tonyhallett
Copy link

Having issues too. Debugging stopped working - cannot find jest.js

@orta
Copy link
Member

orta commented Feb 22, 2018

The IntelliSense is me using @types/jest

all those errors seem to be about vscode-for-flow and not jest?

@seanpoulter
Copy link
Member

Happy to take a look. Could you both provide a simple repo to reproduce the issue, and all the steps required to set up the environment and open the project?

@ueeieiie
Copy link
Author

I'm little new here : )

@orta

  • I'm not using Tpescript or Flow in this project. I added the logs because you might catch something I haven't. So I dont have @types/jest.

@seanpoulter

@rewebit
Copy link

rewebit commented Feb 22, 2018

I am experiencing this same issue on a laptop running Windows 10 Education, with VS code and this extension installed. There are two other developers who are running Macs and the extension works properly.

To eliminate any possible local configuration issues, we took the same project and brought it into an old Mac Mini. On the Mac Mini it works as expected. There is an issue with running this extension on a Windows 10 machine.

@tonyhallett
Copy link

tonyhallett commented Feb 22, 2018

@seanpoulter Have found what is causing my debugging issue. 8e88e30 helpers.ts has changed from my previous version and now does not add .cmd to the pathToJest. When resolvePathToJestBin is called in JestExt.ts a different switch path is taken. The jest file is read but is not of the expected format.

...
case 'jest': {
const lines = fs.readFileSync(jest, 'utf8').split('\n')
switch (lines[0]) {
case '#!/usr/bin/env node': {
return jest
}

      case '#!/bin/sh': {
        const line = lines[8]
        const match = /^\s*"[^"]+"\s+"$basedir\/([^"]+)"/.exec(line)
        if (match) {
          return path.join(path.dirname(jest), match[1])
        }

        break
      }
    }

    break
  }
}

vscode.window.showErrorMessage('Cannot find jest.js file!')
return undefined

}

The workspace against which the extension is running against has devDependency of "jest":^22.3.0 and the jest file in node_modules/.bin is as follows

`#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\,/,g')")

case uname in
CYGWIN) basedir=cygpath -w "$basedir";;
esac

if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../jest/bin/jest.js" "$@"
ret=$?
else
node "$basedir/../jest/bin/jest.js" "$@"
ret=$?
fi
exit $ret`

Running Windows 10 Pro, Node 8.9.1

So for windows users having the same issue upon updating version add to your Workspace/User Settings - "jest.pathToJest": "node_modules/.bin/jest.cmd"

Please advise further.

Thanks

@seanpoulter
Copy link
Member

Thanks for the details @tonyhallett. Either @stephtr or I will have a look as soon as we've got a chance.

@stephtr
Copy link
Member

stephtr commented Feb 22, 2018

The debug issue is indeed a side effect of my commit. As @tonyhallett said it searches now within jest instead of jest.cmd for the path to jest.js, but that wouldn't be a problem. However the regex in JestExt.ts#504 is broken (the dollar sign is not escaped), which is why the detection fails.

@ueeieiie Your repository is working in my VS Code:
jest
Is it possible, that you doesn't have the client folder opened but its parent/root directory? In that case "node_modules/.bin/jest" won't work. The correct setting would be "jest.pathToJest": "client/node_modules/.bin/jest --projects \"client\"".
However if your root project doesn't contain jest as a (dev-)dependency, you have to start the task runner manually after launching VS Code.

@orta orta closed this as completed in #270 Feb 22, 2018
@ueeieiie
Copy link
Author

@stephtr I figured out what was the reason.

The Cause of Problem:

I think Jest was confused by my folders structure.
my folder was like this:

My Project Folder:

     -------/client
               --package.json
               --/node_modules
     -------/server
               --package.json
               --/node_modules
-package.json
-/node_modules

I tried to run Jest's test inside /client, with yarn test running the script of /client's package json.

Solution:

I started to use vscode workspace and made /client and /server/ a root folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants