Skip to content

Commit

Permalink
Fix tests according to the new way of using the browser target
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrus-and committed Aug 17, 2017
1 parent fc870f2 commit cc7d442
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions test/connect.js
@@ -1,6 +1,7 @@
'use strict';

const assert = require('assert');
const url = require('url');

const Chrome = require('../');

Expand Down Expand Up @@ -38,17 +39,28 @@ describe('connecting to Chrome', function () {
});
});
it('should succeed with custom target by full URL', function (done) {
Chrome({'target': 'ws://localhost:9222/devtools/browser'}, function (chrome) {
chrome.close(done);
}).on('error', function () {
assert(false);
Chrome.Version(function (err, info) {
assert.ifError(err);
const browserUrl = info.webSocketDebuggerUrl || 'ws://localhost:9222/devtools/browser';
Chrome({'target': browserUrl}, function (chrome) {
chrome.close(done);
}).on('error', function () {
assert(false);
});
});
});
it('should succeed with custom target by partial URL', function (done) {
Chrome({'target': '/devtools/browser'}, function (chrome) {
chrome.close(done);
}).on('error', function () {
assert(false);
Chrome.Version(function (err, info) {
assert.ifError(err);
if (info.webSocketDebuggerUrl) {
info.webSocketDebuggerUrl = url.parse(info.webSocketDebuggerUrl).pathname;
}
const browserUrl = info.webSocketDebuggerUrl || '/devtools/browser';
Chrome({'target': browserUrl}, function (chrome) {
chrome.close(done);
}).on('error', function () {
assert(false);
});
});
});
it('should succeed with custom target by id', function (done) {
Expand Down Expand Up @@ -139,17 +151,28 @@ describe('connecting to Chrome', function () {
});
});
it('should succeed with custom target by full URL', function (done) {
Chrome({'target': 'ws://localhost:9222/devtools/browser'}).then(function (chrome) {
chrome.close(done);
}).catch(function () {
assert(false);
Chrome.Version(function (err, info) {
assert.ifError(err);
const browserUrl = info.webSocketDebuggerUrl || 'ws://localhost:9222/devtools/browser';
Chrome({'target': browserUrl}).then(function (chrome) {
chrome.close(done);
}).catch(function () {
assert(false);
});
});
});
it('should succeed with custom target by partial URL', function (done) {
Chrome({'target': '/devtools/browser'}).then(function (chrome) {
chrome.close(done);
}).catch(function () {
assert(false);
Chrome.Version(function (err, info) {
assert.ifError(err);
if (info.webSocketDebuggerUrl) {
info.webSocketDebuggerUrl = url.parse(info.webSocketDebuggerUrl).pathname;
}
const browserUrl = info.webSocketDebuggerUrl || '/devtools/browser';
Chrome({'target': browserUrl}).then(function (chrome) {
chrome.close(done);
}).catch(function () {
assert(false);
});
});
});
it('should succeed with custom target by id', function (done) {
Expand Down

0 comments on commit cc7d442

Please sign in to comment.