How to debug javascript tests on Node.js with Selenium WebDriver by breakpoints?
<p>I use WebStorm to write my javascript tests. I have include Selenium WebDriver (+ chromedriver) to run my tests in browser. As a test-runner framework I use Mocha. </p>

<p><strong>The problem is:</strong> when I try to debug my test and set a breakpoint into code, while debugging WebDriver does not starts. And as a result I could not see any variables realtime. </p>

<p>Code example:</p>

<pre><code>// Add external libraries
var test = require('selenium-webdriver/testing'), webdriver = require('selenium-webdriver'), By = require('selenium-webdriver').By;
var mocha = require('./node_modules/mocha/mocha.js'), chai = require('chai'), chaiuse = require('chai-as-promised'), expect = require('chai').expect;
var assert = require('assert');
// global variable for webdriver browser
var browser;
// Main part with test suites
test.describe('Suite 1', function() {
    this.timeout(5000);
    test.beforeEach( function(){ // Executes before each test
        browser = new webdriver.Builder().usingServer().withCapabilities({ 'browserName' : 'chrome', 'timeout' : '5000' }).build();
    });
    test.afterEach( function(){ // Executes after each test
        browser.close();
    });
    test.it('Get Fields', function(done) {
        browser.get('http://google.com');
        var btnFirst = browser.wait(webdriver.until.elementLocated(webdriver.By.name('btnK'), 30000));
        var btnSecond = browser.findElement(webdriver.By.name('btnI')).getAttribute("name");
        btnSecond.then(function(text) {
            console.log("Name of Second button: " + text + "\n");
            assert.equal(text,'btnI','Button with name \'btnI\' not presented');
        });
        done();
    });
});
</code></pre>

<p>And so for now all process is like black-box tests development.</p>

<p>I have tried <a href="https://mattdesl.svbtle.com/debugging-nodejs-in-chrome-devtools" rel="nofollow">DevTools</a> - a chrome console to work. But it just run all test without pause on breakpoints.Command:</p>

<pre><code>devtool node_modules/mocha/bin/_mocha -qc -- ./Tests.js --break
</code></pre>

<p>On C# + Selenium WebDriver I have no problems with step by step debugging, but now I need to do that on JavaScript + Selenium WebDriver.</p>

<p>Please, give an advice?</p>