WebStorm 2019.3.4 upgrade unable to run NodeJS Mocha debugger

Yesterday, I upgraded WebStorm 2019.3.4, full build details posted below.

I was able to run NodeJS Mocha debugger with previous version of WebStorm before upgrade. Now it fails with Unknown "reporter"

/usr/local/Cellar/node/12.12.0/bin/node /Users/jeffrey.tanner/github/ACT/act-archive-microsoft-sharepoint/node_modules/mocha/bin/_mocha -r ts-node/register --timeout 0 --ui bdd --reporter /Applications/WebStorm.app/Contents/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js test/*.ts
Debugger listening on ws://127.0.0.1:53236/969d8089-a3ca-4f91-b669-10886ce1854c
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
mocha inspect [spec..]

Run tests with Mocha

...

✖ ERROR: Unknown "reporter": /Applications/WebStorm.app/Contents/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js

I was able to run NodeJS Mocha debugger with previous version of WebStorm before upgrade.

File does exist:

/Applications/WebStorm.app/Contents/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js

package.json devDependencies for mocha used

@types/mocha": "^7.0.2",
...
"mocha": "^7.1.1"

 

WebStorm 2019.3.4
Build #WS-193.6911.28, built on March 18, 2020
...
Runtime version: 11.0.5+10-b520.38 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.6
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 12
Registry: ide.balloon.shadow.size=0, js.debugger.webconsole=false
Non-Bundled Plugins: BashSupport, com.chrisrm.idea.MaterialThemeUI

Example Mocha Configuration

10 comments
Comment actions Permalink

Works fine for me in 2019.3.4 using similar setup:

 

 

does the issue only occur on debugging (i.e. does Run work)? Can you reproduce the issue in a new project?

0
Comment actions Permalink

Thank you for your reply, much appreciated

  • Same error occurs for both Debug and Run.
  • Can reproduce in a new Project
0
Comment actions Permalink

Please could you share a project the issue can be reproduced in?

0
Comment actions Permalink

That might not be possible. The project's package.json has several proprietary custom modules, internally accessible dependencies. I will see what I can produce for a "Hello World" example.

0
Comment actions Permalink

Please keep me posted:)

0
Comment actions Permalink

I reproduced that and I guess this is somehow related to combination of:

1) typescript-written test, for typescript mixed project, with 'tsconfig.json`

2) currently mocha (9.1.3) thinks it must use esm loader for typescript tests

3) this may be a problematic for loading that reporter with esm loader.

Luckily I cleaned up my project lately of JS and it has only TS now, and i was able to remove the `allowJS` flag, set it to `false`, to be more precise, in `tsconfig.json`.

After this error has gone.

 

0
Comment actions Permalink

Konstantin Isaev please could you clarify what error have you faced namely? from the problem description it seems that your issue is TypeError: Could not load reporter, right? You must have a tsconfig.json with both rootDir and allowJs enabled. The problem occurs because the reporter being used is not under the project rootDir; see https://github.com/microsoft/TypeScript/issues/9858#issuecomment-234379302 for explanation.
You will face the same issue if you create a custom reporter (see https://mochajs.org/api/tutorial-custom-reporter.html, for example), place it outside of your root dir and then run mocha --require ts-node/register --reporter reporters/my-reporter.js test/**/*.spec.ts in terminal

0
Comment actions Permalink

Elena Pogorelova I think I have the very issue you describe. rootDir is set and allowJS:true but the reporter is still not being found.

✖ ERROR: Unknown "reporter": /Users/.../Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.6777.52/IntelliJ IDEA.app/Contents/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js

Any ideas on how to go around this?

0
Comment actions Permalink

>Any ideas on how to go around this?

no workarounds except for disabling either rootDir or allowJs (or both); the problem only occurs if both these options are set. You can create a separate tsconfig.json to be used for running tests if these options are required for your build process

0
Comment actions Permalink

ouch, that's too bad. Thanks for the quick answer anyway.

0

Please sign in to leave a comment.