From 738f2326a6b82f2cc60a16311069e2a09cb30659 Mon Sep 17 00:00:00 2001
From: Craig Nishina <craig.nishina@gmail.com>
Date: Wed, 7 Nov 2018 16:52:19 -0800
Subject: [PATCH] chore(test): clean up mocha tests

- this.slow does not appear to be part of the mocha framework or we are
not correctly exposing it. Removed since it was causing errors.
- moved tests to be async / await where appropriate.
---
 scripts/test.js        |  2 +-
 spec/mocha/lib_spec.js | 36 ++++++++++++++++++++----------------
 spec/mochaConf.js      |  1 +
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/scripts/test.js b/scripts/test.js
index 32b6bf6a3..5405e2cba 100755
--- a/scripts/test.js
+++ b/scripts/test.js
@@ -19,7 +19,7 @@ var passingTests = [
   'node built/cli.js spec/onPrepareFileConf.js',
   'node built/cli.js spec/onPreparePromiseConf.js',
   'node built/cli.js spec/onPreparePromiseFileConf.js',
-  // 'node built/cli.js spec/mochaConf.js',
+  'node built/cli.js spec/mochaConf.js',
   // 'node built/cli.js spec/withLoginConf.js',
   'node built/cli.js spec/suitesConf.js --suite okmany',
   'node built/cli.js spec/suitesConf.js --suite okspec',
diff --git a/spec/mocha/lib_spec.js b/spec/mocha/lib_spec.js
index 9b2f0d056..e469f8d9e 100644
--- a/spec/mocha/lib_spec.js
+++ b/spec/mocha/lib_spec.js
@@ -1,26 +1,26 @@
 // Use the external Chai As Promised to deal with resolving promises in
 // expectations.
-var chai = require('chai');
-var chaiAsPromised = require('chai-as-promised');
+const chai = require('chai');
+const chaiAsPromised = require('chai-as-promised');
 chai.use(chaiAsPromised);
 
-var expect = chai.expect;
+const expect = chai.expect;
 
 // Chai's expect().to.exist style makes default jshint unhappy.
 // jshint expr:true
 
-describe('no protractor at all', function() {
-  it('should still do normal tests', function() {
+describe('no protractor at all', () => {
+  it('should still do normal tests', () => {
     expect(true).to.equal(true);
   });
 });
 
-describe('protractor library', function() {
-  it.skip('should be able to skip tests', function() {
+describe('protractor library', () => {
+  it.skip('should be able to skip tests', () => {
     expect(true).to.equal(false);
   });
 
-  it('should expose the correct global variables', function() {
+  it('should expose the correct global variables', () => {
     expect(protractor).to.exist;
     expect(browser).to.exist;
     expect(by).to.exist;
@@ -28,22 +28,26 @@ describe('protractor library', function() {
     expect($).to.exist;
   });
 
-  it('should wrap webdriver', function() {
+  it('should wrap webdriver', async function() {
     // Mocha will report the spec as slow if it goes over this time in ms.
     this.slow(6000);
-    browser.get('index.html');
+    
+    await browser.get('index.html');
     expect(browser.getTitle()).to.eventually.equal('My AngularJS App');
   });
 
-  describe('with async tests', function() {
-    var finished = false;
+  describe('with async tests', () => {
+    let finished = false;
 
-    it('should wait for async operations to finish', function() {
-      browser.get('index.html').then(function() { finished = true; });
+    it('should wait for async operations to finish', async() => {
+      await browser.get('index.html');
+      finished = true;
     });
 
-    after('verify mocha waited', function() {
-      if(!finished) { throw new Error('Mocha did not wait for async!'); }
+    after('verify mocha waited', () => {
+      if(!finished) {
+        throw new Error('Mocha did not wait for async!');
+      }
     });
   });
 });
diff --git a/spec/mochaConf.js b/spec/mochaConf.js
index 2bd6c74f7..0327e2a77 100644
--- a/spec/mochaConf.js
+++ b/spec/mochaConf.js
@@ -3,6 +3,7 @@ var env = require('./environment.js');
 // A small suite to make sure the mocha framework works.
 exports.config = {
   seleniumAddress: env.seleniumAddress,
+  SELENIUM_PROMISE_MANAGER: false,
 
   framework: 'mocha',