ide-mocha

Send your Mocha test suite's progress to Atom and display it using Atom-IDE-UI components

Robert Rossmann

1,017

2

2.6.0

BSD-3-Clause

GitHub

This package consumes the following services:

IDE-Mocha

Stream Mocha progress to Atom ☕️ + ⚛️ = 🚀

About

This package allows Mocha to send its progress reports (which are normally shown on your Terminal window) to Atom and then do all kinds of interesting things with it, like

IDE-Mocha in action

Installation

Now you can use the custom reporter. The reporter needs to know where to send the progress data. The easiest way to see how to run Mocha is to execute ide-mocha:show-help from the command pallete. 💪 Generally the command looks like this:

# Using automatic socket/port derivation based on project root
npx mocha --reporter mocha-reporter-remote --reporter-options root=${PWD}

# Using Unix socket connections
npx mocha --reporter mocha-reporter-remote --reporter-options address=/var/folders/np/yp1y_nk504b0k61prl2pk4b40000gn/T/mocha-reporter-remote.sock

# Using TCP connections
npx mocha --reporter mocha-reporter-remote --reporter-options address=12345

Each project uses its own socket and port which remains stable even if you quit Atom, so it's safe to persist the socket/port info in your project config/environment variables or any other suitable place. If you don't have "any other suitable place" you can always use ide-mocha:copy-receiver-address from the command pallete to get the socket path/port number for your current session, or ide-mocha:copy-mocha-command to get the full command which you can just paste into a terminal. 💪

Alternatively, you can use the root reporter option to tell the Mocha reporter where your project is located and it will use a deterministic algorithm to arrive at the same socket or port address as Atom so that you do not have to explicitly provide the socket or port to it.

Known issues

... but why?

Because existing Mocha integrations for Atom kinda suck. They either do not work at all, implement custom UI elements which look weird and do not integrate well into Atom (or your current theme 🎨), or force you into giving up your test toolchain because they want to spawn Mocha for you in unexpected ways. This package has no such restrictions - all you need on your end is to install one dev dependency and pass two flags to Mocha to make the whole thing work. And the test suite could be started with a custom binary, make, or heck, even from inside a Docker container (disclaimer: untested but should work in theory)! As long as Mocha can connect to the local socket or TCP port this is guaranteed to work. 💪

Ugly gif

One picture is worth a thousand words, and a gif has many pictures... It's ugly, but it shows all the bits & pieces of this thing.

ide-mocha in action

Contributing

Please do! 🙏 If you have feedback, problems, or ideas, please open an issue and I'll do my best to help you out.

Future plans

License

See the LICENSE file for information.