question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Troubles setting up vs code debugger for Jest

See original GitHub issue

I’m trying to configure the vsCode debugger to debug my jest unit tests. I followed the Nrwl blog post (https://blog.nrwl.io/debugging-nx-in-vs-code-cb1dbe9eeeba) and i can’t get it to work. In fact, after setting up my lunch.json as follows:

{
	"name": "debug-jest",
	"type": "node",
	"request": "launch",
	"program": "${workspaceFolder}/frontends/node_modules/@angular/cli/bin/ng",
	"args": [
		"test",
		"lib-name",
		"--codeCoverage=false",
		"--testNamePattern=test",
		"--testFile=${workspaceFolder}/frontends/libs/test-path"
	],
	"cwd": "${workspaceFolder}/frontends/",
	"console": "internalConsole"
}

the debugger starts and immediately outputs an error:

Exception has occurred: Error
Error: ENOENT: no such file or directory, access 'C:\frontends\node_modules\@angular\cli\models\commands.json'
    at Object.accessSync (fs.js:193:3)
    at Object.existsSync (fs.js:224:8)
    at Object.findUp (C:\frontends\node_modules\@angular\cli\utilities\find-up.js:21:22)
    at Object.runCommand (C:\frontends\node_modules\@angular\cli\models\command-runner.js:50:42)
    at default_1 (C:\frontends\node_modules\@angular\cli\lib\cli\index.js:32:54)
    at Object.<anonymous> (C:\frontends\node_modules\@angular\cli\lib\init.js:120:1)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)

Am I doing something wrong?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
Tre665commented, Aug 6, 2019

I also had issues to get the debugging working in vscode. The nicest solution that worked for me was the config from @toddwseattle. He shared his config in this gist.

You can also find a discussion in the vscode jest repo here

What this solution makes it super nice is, that it also offers a selection menu for the lib that you want to debug. I think this is pretty handy in a monorepo environment.

0reactions
FrozenPandazcommented, May 29, 2020

Hi, sorry about this.

This was mislabeled as stale. We are testing ways to mark not reproducible issues as stale so that we can focus on actionable items but our initial experiment was too broad and unintentionally labeled this issue as stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode debugger not working in Jest tests - Stack Overflow
This configuration let's me debug the jest test. Unfortunately hitting a breakpoint in the component does not show the correct line ...
Read more >
Troubleshooting - Jest
There are multiple ways to debug Jest tests with Visual Studio Code's built-in debugger. ... More information on Node debugging can be found...
Read more >
How to debug Jest tests with VSCode (2021 Version)
Steps: · Make directory for project mkdir debug-test · Navigate to directory cd debug-test · Initialize NPM npm init -y · Configure package...
Read more >
vscode-jest - Visual Studio Marketplace
Simply open Jest - Visual Studio Marketplace and click "Install". Alternatively open Visual Studio Code, go to the extension view and search for ......
Read more >
Debug Jest TypeScript in VS Code, Monorepo Edition
In this article, you'll learn about setting up VS Code to debug your TypeScript Jest test cases. By the end, you'll have a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found