diff --git a/spec/unit/driverProviders/local_test.js b/spec/unit/driverProviders/local_test.js index 052282551..2ad101674 100644 --- a/spec/unit/driverProviders/local_test.js +++ b/spec/unit/driverProviders/local_test.js @@ -8,19 +8,19 @@ var WriteTo = require('../../../built/logger').WriteTo; var Local = require('../../../built/driverProviders').Local; var webdriver, file; -describe('local connect', function() { - beforeEach(function() { +describe('local connect', () => { + beforeEach(() => { ProtractorError.SUPRESS_EXIT_CODE = true; Logger.setWrite(WriteTo.NONE); }); - afterEach(function() { + afterEach(() => { ProtractorError.SUPRESS_EXIT_CODE = false; Logger.setWrite(WriteTo.CONSOLE); }); - describe('without the selenium standalone jar', function() { - it('should throw an error jar file is not present', function() { + describe('without the selenium standalone jar', () => { + it('should throw an error jar file is not present', async () => { var config = { capabilities: { browserName: 'chrome' }, seleniumServerJar: '/foo/bar/selenium.jar' @@ -28,7 +28,7 @@ describe('local connect', function() { var errorFound = false; try { webdriver = new Local(config); - webdriver.setupEnv(); + await webdriver.setupEnv(); } catch(e) { errorFound = true; expect(e.code).toBe(BrowserError.CODE); @@ -37,8 +37,8 @@ describe('local connect', function() { }); }); - describe('with the selenium standalone jar', function() { - it('should throw an error if the jar file does not work', function() { + describe('with the selenium standalone jar', () => { + it('should throw an error if the jar file does not work', async () => { var jarFile = ''; beforeEach(function() { // add files to selenium folder @@ -54,7 +54,7 @@ describe('local connect', function() { } }); - it('should throw an error if the selenium sever jar cannot be used', function() { + it('should throw an error if the selenium sever jar cannot be used', () => { var config = { capabilities: { browserName: 'foobar explorer' }, seleniumServerJar: jarFile @@ -73,7 +73,7 @@ describe('local connect', function() { }); describe('binary does not exist', () => { - it('should throw an error if the update-config.json does not exist', () => { + it('should throw an error if the update-config.json does not exist', async () => { spyOn(fs, 'readFileSync').and.callFake(() => { return null; }); var config = { capabilities: { browserName: 'chrome' }, @@ -82,7 +82,7 @@ describe('local connect', function() { var errorFound = false; try { webdriver = new Local(config); - webdriver.setupDriverEnv(); + await webdriver.setupDriverEnv(); } catch(e) { errorFound = true; expect(e.code).toBe(BrowserError.CODE); diff --git a/spec/unit/runner_test.js b/spec/unit/runner_test.js index 411c0aeb1..fa68be8cd 100644 --- a/spec/unit/runner_test.js +++ b/spec/unit/runner_test.js @@ -2,69 +2,71 @@ var Runner = require('../../built/runner').Runner; var Logger = require('../../built/logger').Logger, WriteTo = require('../../built/logger').WriteTo; -describe('the Protractor runner', function() { - beforeAll(function() { +describe('the Protractor runner', () => { + beforeAll(() => { Logger.writeTo = WriteTo.NONE; }); - afterAll(function() { + afterAll(() => { Logger.writeTo = WriteTo.CONSOLE; }); - it('should export its config', function() { - var config = { + it('should export its config', () => { + const config = { foo: 'bar' }; - var runner = new Runner(config); + const runner = new Runner(config); expect(runner.getConfig()).toEqual(config); }); - it('should run', function(done) { - var config = { + it('should run', async () => { + const config = { mockSelenium: true, specs: ['*.js'], framework: 'debugprint' }; - var exitCode; - var runner = new Runner(config); + let exitCode; + const runner = new Runner(config); runner.exit_ = function(exit) { exitCode = exit; }; - runner.run().then(function() { - expect(exitCode).toEqual(0); - done(); - }); + await runner.run() + expect(exitCode).toEqual(0); }); - it('should fail with no specs', function() { - var config = { + it('should fail with no specs', async () => { + const config = { mockSelenium: true, specs: [], framework: 'debugprint' }; - var exitCode; - Runner.prototype.exit_ = function(exit) { - exitCode = exit; - }; - var runner = new Runner(config); - expect(function() { - runner.run(); - }).toThrow(); + const runner = new Runner(config); + let errMessage = 'No error found'; + try { + await runner.run() + } catch (err) { + errMessage = err.message; + } + expect(errMessage).not.toBe('No error found'); }); - it('should fail when no custom framework is defined', function(done) { - var config = { + it('should fail when no custom framework is defined', async () => { + const config = { mockSelenium: true, specs: ['*.js'], framework: 'custom' }; - var runner = new Runner(config); - runner.run().then(function() { - done.fail('expected error when no custom framework is defined'); - }, done); + const runner = new Runner(config); + let errMessage = 'No error found'; + try { + await runner.run() + } catch (err) { + errMessage = err.message; + } + expect(errMessage).not.toBe('No error found'); }); });