Looping through tests in Nightwatch using Mocha
<p>I'm using Nightwatch with Mocha to write some automated (dynamic) tests. Dynamic in the sense that I want to load some of the data dynamically which is used in looping through test cases. See code below. I am struggling with three items:</p>

<ol>
<li>Let's say I end up with 3 items in my testArray. When it loops in the test (it), its only opens one browser, goes to google.com and doesn't start 2 other browsers.  I'm sure this is related to some async issue I'm having but I don't know how to resolve it. </li>
<li>Continuing from #1, the first (and only browser opened) doesn't even close at the conclusion.  Again an async issue with some aspect of using done().</li>
<li>Ideally I would like to dynamically name the test while it's running. i.e., instead of it("foo"... I would like to either have the loop around the it and pass in the title (which I can't get working right) or somehow change it within the test (it) code dynamically.</li>
</ol>

<p>Note that I don't need to use Mocha with Nightwatch but I started going down the path of using Mocha's dynamic test feature (new TestCase) but I couldn't get that working either. </p>

<p>Here is a scaled-down version of my code.</p>

<pre><code>var testArray = [];

describe('createArray', function() {
  before(function(client, done) {
    // do some async operations within a loop and create testArray entries
    // loop {
        testArray.push(foo); // let's say I end up with 3 items.
    // }
    done();
  });

  it('foo', function(client) {
    console.log(testCaseArray);
    testCaseArray.forEach(function(testCase) {
      client.url("http://www.google.com"); // let's say here I would eventually want to have something like client.url("http://....." + testCase.value)
    });
  });
 });
</code></pre>

<p>Thanks in advance.</p>