How can I run mocha tests remotely on IntelliJ IDEA 13 (or WebStorm)?

IntelliJ IDEA 13 has excellent support for Mocha tests through the Node.js plugin: https://www.jetbrains.com/idea/webhelp/running-mocha-unit-tests.html

The problem is that when I edit the code on my local machine, I have a virtual machine (tramp) in which I run and check the code so that it is as productive as possible.

I wrote a small bash script to run my tests remotely on this virtual machine whenever I call "Run" from IntelliJ, and the results appear on the console quite well, however I would love to use a great interface that appears whenever it starts test runner Mocha.

Any ideas?

+3
intellij-idea vagrant mocha
source share
2 answers

Update: There is a much better way to do it now. See https://github.com/TechnologyAdvice/fake-mocha


Success!!

Here is how I did it. This is specific for connecting back to strollers, but can be changed for any remote server on which you have key-based SSH privileges.

  • Somewhere on your remote computer or even inside your code base, store the NodeJS plugin mocha reporter (.js files at the time of this writing). They are located in NodeJS/js/mocha in your main IntelliJ configuration folder, which is on OSX ~/Library/Application Support/IntelliJIdea13 . Know the absolute path to where you placed them.
  • Edit "Run Configurations"
  • Add a new one using 'Mocha'
  • Set the 'Node interpreter' to the full path to your ssh executable. On my machine, this is /usr/bin/ssh .
  • Set the β€œNode parameters” to this hippo, setting up your own configuration if necessary: -i /Users/USERNAME/.vagrant.d/insecure_private_key vagrant@MACHINE_IP "cd /vagrant; node_modules/mocha/bin/_mocha --recursive --timeout 2000 --ui bdd --reporter /vagrant/tools/mocha_intellij/mochaIntellijReporter.js test" # REMEMBER! # at the end is IMPORTANT, as it undoes everything else, which adds Mocha run config to this command. Also, be sure to use the absolute path wherever I have it.
  • Set the "Working Directory", "Mocha package" and "Test directory" exactly what they should be if you run mocha tests locally. This will not affect the execution of the test, but this interface will check to make sure that these are valid paths.
  • Name it, save and run!

Fully integrated bliss of distance testing.

+5
source share

1) In Webstorm, create a Remote Debug configuration using port 5858.
2) Make sure the port is open on your server or virtual machine.
3) On the remote server, run Mocha with the option --debug-brk : mocha test --debug-brk
4) Return to Webstorm, run the remote debugger that you created in step 1, and execution should pause at the given breakpoints.

0
source share

All Articles