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
88 additions
and
5 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 path = require('path'); | ||
var fs = require('fs'); | ||
var BrowserError = require('../../../built/exitCodes').BrowserError; | ||
|
||
var removeSeleniumFolder = function() { | ||
try { | ||
var directory = path.resolve('selenium'); | ||
var files = fs.readdirSync(directory); | ||
for (var pos = 0; pos < files.length; pos++) { | ||
fs.unlinkSync(path.resolve(directory, files[pos])); | ||
} | ||
fs.rmdirSync(directory); | ||
} catch(e) { } | ||
}; | ||
|
||
describe('direct connect', function() { | ||
describe('without the selenium driver', function() { | ||
beforeEach(function() { | ||
removeSeleniumFolder(); | ||
}); | ||
|
||
it('should throw an error if no drivers are present', function() { | ||
var config = { | ||
directConnect: true, | ||
capabilities: { browserName: 'chrome' } | ||
}; | ||
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() { | ||
beforeEach(function() { | ||
// add files to selenium folder | ||
var directory = path.resolve('selenium'); | ||
fs.mkdirSync(directory); | ||
var file = 'chromedriver_' + require('../../../config.json').webdriverVersions.chromedriver; | ||
fs.openSync(path.resolve(directory, file), 'w'); | ||
}); | ||
|
||
afterEach(function() { | ||
removeSeleniumFolder(); | ||
}); | ||
|
||
it('should throw an error if the driver cannot be used', function() { | ||
var config = { | ||
directConnect: true, | ||
capabilities: { browserName: 'foobar explorer' } | ||
}; | ||
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); | ||
}); | ||
}); | ||
}); |