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.

`node --inspect-brk jest --runInBand --watch` doesn't stop on breakpoint or debugger statement.

See original GitHub issue

šŸ› Bug Report

node --inspect-brk jest --runInBand --watch
doesnā€™t stop on breakpoints or debugger statement whereas
node --inspect-brk jest --runInBand
will (no --watch flag)

Noe: It is using ts-jest 23.0.0

jest.config.js

module.exports = {
    globals: {
        "ts-jest": {
            skipBabel: true,
            enableTsDiagnostics: true,
            disableSourceMapSupport: true
        }
    },
    roots: [
        "<rootDir>/src",
        "<rootDir>/tests"
    ],
    transform: {
        "^.+\\.tsx?$": "ts-jest"
    },
    testRegex: "(/tests/.*.(test|spec)).ts$",
    moduleFileExtensions: [
        "js",
        "ts",
        "json",
        "node"
    ],
    setupTestFrameworkScriptFile: "jest-extended",
    verbose: true
};

Expected behavior

I would expect debugging to work with --watch

Run npx envinfo --preset jest

it errors with

(node:2536) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of null
node --version
v10.0.0

jest version
23.4.0

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:31
  • Comments:38 (12 by maintainers)

github_iconTop GitHub Comments

20reactions
jamietrecommented, Jul 19, 2018

I started having trouble again after downgrading to 23.1.0, and after pulling some hair out I got things to work reliably by using --no-cache when invoking Jest. This also seems to solve the problem with the latest Jest release too. Itā€™s not clear to me why just downgrading Jest to the version that had been working reliably before didnā€™t work, but there are so many moving parts that have changed in last few weeks (VS Code version, typescript, jest, ts-jest) I assume there are other things involved.

I tried the following:

jest --inspect --watch

Breakpoints are unverified. Debugging doesnā€™t work at all

jest --clearCache
jest --inspect --watch

Breakpoints are verified. Stops on breakpoints the first run only. After changing something resulting in tests restarting, vscode still shows verified breakpoints, but the debugger doesnā€™t work any more.

jest --no-cache --inspect --watch

Seems to work reliably.

So thereā€™s something wrong with the way sourcemaps are cached, apparently, and it isnā€™t just old/invalid cached information lying around from an older version of something, since clearing the cache only results in it working once.

17reactions
ravihugocommented, Aug 31, 2018

Ran into this, took about 5 hours thinking my VSCode was malfunctioning. If anyone else has a workflow of running jest in watch mode, then using VSCode to ā€œAttach by Process IDā€, I recommend modifying your command line to:

jest --watch --no-cache --runInBand
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Jest
When Jest executes the test that contains the debugger statement, execution will pause and you can examine the current scope and call stack....
Read more >
How do you debug Jest Tests? - Stack Overflow
Open the command palette and start Debug: JavaScript Debug Terminal : ... node --inspect-brk <path to jest.js> --runInBand <path to yourĀ ...
Read more >
Jest Configuration And Debugging Jest Based Tests
Use the below command to execute the test in a breakpoint mode. /usr/local/bin/node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand. #Ā ...
Read more >
7 Ways to Debug Jest Tests in Terminal - Pragmatic Pineapple
Put a debugger statement somewhere in your code (testing or production one). Run node --inspect-brk node_modules/.bin/jest --runInBand [anyĀ ...
Read more >
Debug Jest Tests - YouTube
Here we'll cover how you can run your jest tests in Chrome's DevTools using node -- inspect - brk. Sometimes it's just really...
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