Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Mocha with IntelliJ

I am trying to configure Mocha for IntelliJ, and when Googling, I keep finding posts that say "install the mocha plugin".

I don't have a Mocha plugin. I go to Settings → Plugins → (install JetBrains plugin) / (browse repositories) but when I type mocha it comes up empty.

(Side question: can anyone tell me the difference between the menu options above, please?)

What am I missing?

These are the posts I've run into so far:

  • https://www.jetbrains.com/idea/webhelp/running-mocha-unit-tests.html
  • How can I run mocha tests remotely on IntelliJ IDEA 13 (or WebStorm)?
like image 362
guy mograbi Avatar asked Sep 03 '14 05:09

guy mograbi


People also ask

How do I add a mocha?

Install Mocha In the embedded Terminal ( Alt+F12 ) , type one of the following commands: npm install mocha for local installation in your project. npm install -g mocha for global installation. npm install --save-dev mocha to install Mocha as a development dependency.


3 Answers

Mocha integration is included with another plugin (I'm going to guess the NodeJS plugin). If you install that plugin, and then go to manually add a Run Configuration, mocha will be an option . In the Webstorm 7.0.2 blog post, there is an embedded YouTube video which shows you how to configure a Mocha test directory:

http://blog.jetbrains.com/webstorm/2013/11/webstorm-7-0-2-is-available/

like image 68
Bill Poitras Avatar answered Sep 20 '22 22:09

Bill Poitras


You dont have to install Mocha Plugin. Infact Mocha is not available as plugin in IntelliJ IDEA IDE. Just install Node & using node package manager install Mocha.

From Menu click on Run > Edit Configuartion Click on Add button (+ icon) & select Mocha from here. Specify Working Directory, Test Directory, Mocha Package (Local node module folder where Mocha is installed) & you are good to go.

like image 34
SharpCoder Avatar answered Sep 21 '22 22:09

SharpCoder


Mocha comes bundled with the NodeJS plugin in IntelliJ Idea.

If you don't have it, install the NodeJS plugin:

Preferences > Plugins > NodeJS
like image 43
klmlfl Avatar answered Sep 22 '22 22:09

klmlfl