Mocha tests ignore all breakpoints in TypeScript files when running in debug mode


When clicking on the 'Debug <test name>' button offered by a drop-down menu beside any describe() or it() statement in a Mocha test, my tests run, but all breakpoints are ignored. Here is the console output (I've added backslashes to the command-line invocation for legibility):


/usr/local/bin/node \
--inspect-brk=60316 \
/Users/me/project/node_modules/mocha/bin/_mocha \
--require ts-node/register \
--timeout 0 \
--ui bdd \
--reporter "/Users/me/Library/Application Support/JetBrains/Toolbox/apps/WebStorm/ch-0/182.3684.70/" \
--grep "^Resume Contentposition should be accurately calculated\.$"

Debugger listening on ws://
For help, see:
Debugger attached.
Waiting for the debugger to disconnect...

AssertionError: expected 90 to equal 110
Expected :110
Actual :90
<Click to see difference>

at Context.<anonymous> (test/src/ads/Resume.ts:111:82)

Here is my mocha.opts:

--require tsconfig-paths/register
--require test/node-dom-shim.js
--require ignore-styles

The 'Mute Breakpoints' button is not active, and clicking 'View Breakpoints' confirms that I have many, many breakpoints set (trying to get any breakpoint to activate in case it's just a case of the .ts -> .js source-maps being broken). See the screenshot below for a sanity check.

Here are the main parts of my package.json for reference:

"devDependencies": {
"@types/chai": "4.1.4",
"@types/mocha": "5.2.5",
"mocha": "5.2.0",
"ts-loader": "3.2.0",
"ts-node": "7.0.0",
"tsconfig-paths": "2.7.3",
"typescript": "2.6.2",

Why aren't my breakpoints being hit despite the program being able to run all the way to line 111 (where there is a failing test)?

EDIT: Experiencing this on Webstorm 2018.2.


debugging works fine for me using mocha + ts-node. I'm using

"dependencies": {
"@types/chai": "^4.1.4",
"@types/chai-http": "^3.0.5",
"@types/mocha": "^5.2.5",
"chai": "^4.1.2",
"chai-http": "^4.0.0",
"express": "^4.16.3",
"mocha": "^5.2.0",
"ts-node": "^7.0.0",
"typescript": "^3.0.1"

please share a sample project I can use to recreate the issue


Hi Elena,

It's inexplicably working for me again this morning. All I did was restart my computer. I'm surprised that this helped, as re-installing mocha and ts-node didn't, and I'm pretty sure that I'd had this problem for two days in a row already despite restarts. I notice that this time, the red circles indicating breakpoints now have a tick upon them (denoting them as confirmed breakpoints), whereas in my screenshot they did not.

Lacking any proper diagnosis for this, but at least having it working again, I shall declare this support issue as closed.


I have the same testing code in 2 projects, that I have opened at the same time. In one project the break point at the start of the first test in the file work perfectly. In the second IDE with the SAME TEST CODE - it runs through all the tests, marks them as successful and ignores all the break points. :(

Could use some help this frustrating stuff


Nevermind - doing the kind of thing that makes a help desk person roll their eyes at the stupidity - put the wrong file in the config for the test runner.


Please sign in to leave a comment.