Jest: Error when trying to debug jest test in webpack repo

Created on 21 Jun 2018  ·  8Comments  ·  Source: facebook/jest

🐛 Bug Report

Following jests troubleshooting guide

Debug a jest test fails with:

VM88 C:Users...webpacknode_modulesjest-clibuildcliindex.js:23 ● Unrecognized CLI Parameters:

 Following options were not recognized:
 ["inspect-brk", "inspectBrk"]

 CLI Options Documentation:
 https://facebook.github.io/jest/docs/en/cli.html


A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior:
launch.config (VsCode) with below config and hit F5.

   { "name": "Jest Current File",
        "type": "node",
        "request": "launch",
      "args": [
          "${workspaceFolder}/test/configCases/ignore/only-resource-context/test.js"
        ],
        "runtimeArgs": [
          "--inspect-brk",
          "${workspaceRoot}/node_modules/jest/bin/jest.js",
          "--runInBand"
        ],
        "console": "integratedTerminal",
        "internalConsoleOptions": "neverOpen"
      }

image

image

Expected behavior

A clear and concise description of what you expected to happen.

  • no errors

Link to repl or repo (highly encouraged)

Try to debug a certain jest test in webpack repo
for details, see launch.config above.

Run npx envinfo --preset jest

Paste the results here:

npx: installed 1 in 2.325s
Path must be a string. Received undefined
npx: installed 1 in 2.293s
C:UsersxxxAppDataRoamingnpm-cache_npx15888node_modulesenvinfodistcli.js

System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz
Binaries:
Yarn: 1.6.0 - C:UsersxxxAppDataRoamingnpmyarn.CMD
npm: 5.8.0 - C:Program Filesnodejsnpm.CMD


Documentation Help Wanted

Most helpful comment

I remember that I used the Linux configuration which was already in the document to create the one for Windows. I'm certain that it was working at that time, but I think things changed ever since in VS Code. Currently, I'm using the following configuration for Windows and works fine for me:
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceRoot}/node_modules/jest/bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}

All 8 comments

It looks like you're sending the --inspect-brk arg to Jest instead of only node. Unfortunately this issue tracker is not a help forum. We recommend using our discord channel or StackOverflow where there is an active jestjs tag for questions

The configuration above is copy/pasted from YOUR trouble shooting guide and type:node is specified.

The configuration on your site specifies only runtimeArgs which are usually only supplied to node,
why are they overhanded to the jest-cli is the question, right?!

The jest-CLI complains about it:

debugger:///VM88 C:UsersxxxDocuments_Github_Repositorieswebpacknode_modulesjest-clibuildcliindex.js

41746625-4f6e3020-75ab-11e8-921f-04ace7f655d7 1

Ah, got it. @papadi I see you added these docs, could you confirm this is a bug?

I remember that I used the Linux configuration which was already in the document to create the one for Windows. I'm certain that it was working at that time, but I think things changed ever since in VS Code. Currently, I'm using the following configuration for Windows and works fine for me:
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceRoot}/node_modules/jest/bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}

Actually now I remember that I got the config above from this vscode recipe. Perhaps jest docs should refer to this document now: https://github.com/Microsoft/vscode-recipes/tree/master/debugging-jest-tests

@papadi Yes, your config works.
The difference is that I have removed this part:

 "runtimeArgs": [
          "--inspect-brk",
          "${workspaceRoot}/node_modules/jest/bin/jest.js",
          "--runInBand"
        ],

In respect to the error message it seems that node passes to runtime arguments to jest-cli, which obviously shouldn't be the case...

Closing the issue as it works without passing runtimeArgs.

Nevertheless, the docs could be updated.

Thanks!

Btw. the error msg in the CLI also looks strange... ;-)

PR welcome for whatever works best!

Was this page helpful?
0 / 5 - 0 ratings