This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(exitCodes): adding exit code for direct connect errors
- Loading branch information
Showing
3 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
var fs = require('fs'), | ||
os = require('os'), | ||
path = require('path'); | ||
var BrowserError = require('../../../built/exitCodes').BrowserError, | ||
Logger = require('../../../built/logger2').Logger, | ||
WriteTo = require('../../../built/logger2').WriteTo; | ||
|
||
describe('direct connect', function() { | ||
beforeEach(function() { | ||
Logger.setWrite(WriteTo.NONE); | ||
}); | ||
|
||
afterEach(function() { | ||
Logger.setWrite(WriteTo.CONSOLE); | ||
}); | ||
|
||
describe('without the selenium driver', function() { | ||
it('should throw an error if no drivers are present', function() { | ||
var config = { | ||
directConnect: true, | ||
capabilities: { browserName: 'chrome' }, | ||
chromeDriver: '/foo/bar/chromedriver' | ||
}; | ||
var errorFound = false; | ||
try { | ||
webdriver = require('../../../built/driverProviders/direct')(config); | ||
webdriver.getNewDriver(); | ||
} catch(e) { | ||
errorFound = true; | ||
expect(e.code).toBe(BrowserError.CODE); | ||
} | ||
expect(errorFound).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('with selenium drivers', function() { | ||
var chromedriver = ''; | ||
beforeEach(function() { | ||
// add files to selenium folder | ||
file = 'chromedriver_' + require('../../../config.json').webdriverVersions.chromedriver; | ||
chromedriver = path.resolve(os.tmpdir(), file); | ||
fs.openSync(chromedriver, 'w'); | ||
}); | ||
|
||
afterEach(function() { | ||
try { | ||
fs.unlinkSync(chromedriver); | ||
} catch(e) { | ||
} | ||
}); | ||
it('should throw an error if the driver cannot be used', function() { | ||
var config = { | ||
directConnect: true, | ||
capabilities: { browserName: 'foobar explorer' }, | ||
chromeDriver: chromedriver | ||
}; | ||
var errorFound = false; | ||
try { | ||
webdriver = require('../../../built/driverProviders/direct')(config); | ||
webdriver.getNewDriver(); | ||
} catch(e) { | ||
errorFound = true; | ||
expect(e.code).toBe(BrowserError.CODE); | ||
} | ||
expect(errorFound).toBe(true); | ||
}); | ||
}); | ||
}); |