Skip to content

nullromo/jest-debugger-example

Repository files navigation

Jest Node Debugger Example Repo

I am trying to use the debugger but I can't get it to work. This minimal sample repo shows how I set up my project.

Setup

  1. Use basic tsconfig.json file.
  2. Install stuff from npm (npm i --save-dev typescript jest babel-jest @babel/core @babel/preset-env @babel/preset-typescript @jest/globals).
  3. Create babel.config.js as recommended.
  4. Create a basic file (run.ts).
  5. Create a test file (run.test.ts).

Run WITHOUT Jest

  1. Open Google Chrome and go to chrome://inspect/#devices.
  2. Click on "Open dedicated DevTools for Node".
  3. Run the program with node --inspect-brk run.ts
  4. Wait a few seconds
  5. Boom, the debugger window picks up the code and everything is good to go.

Debugger without Jest

Run WITH Jest

  1. Same as above, but run node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand instead.
  2. The debugger attaches, but none of the source code is there.
  3. Now what?

Debugger with Jest

Note that the only file picked up in the left-hand side is jest.js. The debugger does not know about any of my source files.

I also tried adding --require ts-node/register to the command (after npm i --save-dev ts-node). After that, it picks up a bunch of files in node_modules, but none of my actual source files.

image

I also added "soruceMap": true to my tsconfig.json, but that didn't seem to have any effect.

Notes

Here is a Stack Overflow question that I asked about this, with no response and 1 close vote as of 02/09/26.

Here is a GitHub issue that I opened against Jest about this.

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors