title: Javascript sync with wd-sync in mocha test
body: <p>can you help with my sync-problem in mocha test?</p>
  
  <p>I have this test in mocha, I use <a href="https://www.npmjs.com/package/wd-sync" rel="nofollow noreferrer">wd-sync</a> and <a href="https://www.npmjs.com/package/resemble" rel="nofollow noreferrer">resemble</a> packages. </p>
  
  <p>wd-sync is for avoiding Promises and callback hell and it is great package, but I figured out that it has some problems. It doesn't wait for resemble so this part is executed out of test cases. I tried add resemble to Promise but without success so now I am out of ideas.</p>
  
  <p>This is my <strong>log</strong> from mocha - As you can see, <code>console.log(inside)</code> is executed out of test cases <code>PROMISE_002</code>, test pass, but it should fails. <code>After all hook</code> fails, because <code>expected</code> is executed during this step.</p>
  
  <pre><code>  Screenshot functionality
  1
  2
  3
  4
      ✓ PROMISE_002 (3714ms)
  inside
  inside2
      1) "after all" hook
  
  
    1 passing (16s)
    1 failing
  
    1) Screenshot functionality "after all" hook:
       Uncaught AssertionError: expected '0.01' to equal 5
  </code></pre>
  
  <p>My test:</p>
  
  <pre><code>it.only('PROMISE_002', wrap(function(){
      const date = new Date();
      const path = `${date.getFullYear()}${date.getMonth()}${date.getDate()}`;
      const dir = `archiveServer/${path}`;
  
      if (!fs.existsSync(dir)) {
          fs.mkdirSync(dir);
      }
  
      console.log(1);
      driver.saveScreenshot(`archiveServer/baseline/PROMISE_002.png`);
      console.log(2);
      driver.saveScreenshot(`${dir}/PROMISE_002.png`);
      console.log(3);
  
      resemble(`${dir}/PROMISE_002.png`)
          .compareTo('archiveServer/baseline/PROMISE_002.png')
          .onComplete(function (data) {
              //if (data.misMatchPercentage &gt; 0.5) {
              console.log('inside');
              data.getDiffImage()
                  .pack()
                  .pipe(fs.createWriteStream(`${dir}/PROMISE_002-diff.png`));
              console.log('inside2');
              expect(data.misMatchPercentage).to.equal(5);
          });
  
      console.log('4');
  }));
  </code></pre>