Auto-launching Chrome to Debug Mocha Tests on Mac

March 22, 2017 § Leave a comment

Are you tired of cutting and pasting URLs from node –inspect to launch Chrome?


This is what happens today:

$ alias mocha="node_modules/mocha/bin/mocha"
$ alias mocha-debug="mocha --debug-brk --inspect --compilers ts:ts-node/register --recursive test/**/*-spec.ts"
$ mocha-debug
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
    chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/2dcfe97d-49c4-40bc-8639-51e1508dc09d

Right now I need to manually launch Chrome and paste in that URL, which is a pain.  After much experimentation, I finally found a StackOverflow question that pointed me to inspect-process. Now I can just do:

$ npm install -g inspect-process

$ inspect node_modules/mocha/bin/_mocha --compilers ts:ts-node/register --recursive test/**/*-spec.ts

Whew!  I am posting this here in the hopes it will help other people find the information more easily.

Advertisements

Tagged: , , ,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading Auto-launching Chrome to Debug Mocha Tests on Mac at iHack, therefore iBlog.

meta

%d bloggers like this: