Skip to content

Commit

Permalink
fix: browserstack using wrong hostname (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmalinowski authored Feb 22, 2021
1 parent 8839153 commit 3d7bc86
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ jobs:

local-integration-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
browser: [headlessChrome, headlessFirefox]
steps:
- name: Ensure that Chrome is present
run: google-chrome --version
- name: Ensure that Firefox is present
run: firefox --version
- name: Checkout
uses: actions/checkout@v1
- name: Fix ssh+git access for public submodules
Expand All @@ -91,6 +91,4 @@ jobs:
- run: npm run build:debug
- run: npm run build:prod
- name: Local integration tests using Headless Chrome
run: npm run test:integration:local:_execute
- name: Local integration tests using Firefox
run: npm run test:integration:local:headlessFirefox:_execute
run: npm run test:integration:local:${{ matrix.browser }}:_execute
2 changes: 1 addition & 1 deletion integration-tests/utils/browserstack.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const nightwatch_config = {
project: require('../../package.json').name,
},
globals: {
host: 'bs-local.com',
hostname: 'bs-local.com',
enableHttps: true, // this is for our server
}
},
Expand Down
7 changes: 3 additions & 4 deletions integration-tests/utils/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ module.exports = {
defaultTimeout = -10000;
}

const backend = await buildIntegrationBackend({
enableHttps: browser.globals.enableHttps,
});
browser.globals._closeBackend = backend.close;
browser.globals.buildIntegrationBackend = () => buildIntegrationBackend({
enableHttps: browser.globals.enableHttps,
hostname: browser.globals.hostname,
});
const backend = await browser.globals.buildIntegrationBackend();
browser.globals._closeBackend = backend.close;

browser.globals.httpPort = backend.httpPort;
browser.globals.clearReceivedSpans = backend.clearReceivedSpans;
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/utils/local.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const nightwatch_config = {
acceptInsecureCerts: true,
},
globals: {
host: 'localhost',
hostname: 'localhost',
enableHttps: true,
},
},
Expand Down Expand Up @@ -94,6 +94,7 @@ const nightwatch_config = {
acceptInsecureCerts: false,
},
globals: {
hostname: 'localhost',
enableHttps: false,
},
},
Expand Down
10 changes: 4 additions & 6 deletions integration-tests/utils/testBackendProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

const { runIntegrationDevelopmentServer } = require('../devServer/devServer');

exports.buildIntegrationBackend = async ({ enableHttps }) => {
exports.buildIntegrationBackend = async ({ enableHttps, hostname }) => {
const spans = [];
function handleSpanReceived(span) {
spans.push(span);
Expand All @@ -26,9 +26,7 @@ exports.buildIntegrationBackend = async ({ enableHttps }) => {
close,
httpProtocol,
httpPort,
httpHostname,
websocketsProtocol,
websocketsHostname,
websocketsPort,
getLastServerTiming,
} = await runIntegrationDevelopmentServer({
Expand All @@ -42,7 +40,7 @@ exports.buildIntegrationBackend = async ({ enableHttps }) => {
};

function getUrl (path = '/', includedParams = Object.keys(availableSearchParams), otherParams = {}) {
const url = new URL(path, `${httpProtocol}://${httpHostname}:${httpPort}`);
const url = new URL(path, `${httpProtocol}://${hostname}:${httpPort}`);
includedParams.forEach((name) => {
url.searchParams.set(name, availableSearchParams[name]);
});
Expand All @@ -51,7 +49,7 @@ exports.buildIntegrationBackend = async ({ enableHttps }) => {
}

function getWebsocketsUrl() {
return new URL(`${websocketsProtocol}://${websocketsHostname}:${websocketsPort}`);
return new URL(`${websocketsProtocol}://${hostname}:${websocketsPort}`);
}

console.log(`Running integration tests server at: ${getUrl()}`);
Expand All @@ -65,6 +63,6 @@ exports.buildIntegrationBackend = async ({ enableHttps }) => {
getUrl,
getWebsocketsUrl,
httpPort,
httpHostname,
httpHostname: hostname,
};
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
"lint": "eslint src/*.js test/*.js integration-tests/**/*.js integration-tests/**/**/*.js",
"lint:markdown": "markdownlint README.md docs/*.md",
"lint:fix": "eslint --fix src/*.js test/*.js integration-tests/**/*.js integration-tests/**/**/*.js",
"test:integration:local": "npm-run-all -s build:development test:integration:local:_execute",
"test:integration:local": "npm-run-all -s build:development test:integration:local:headlessChrome:_execute",
"test:integration:local:firefox": "npm-run-all -s build:development test:integration:local:firefox:_execute",
"test:integration:local:chrome": "npm-run-all -s build:development test:integration:local:chrome:_execute",
"test:integration:local:safari": "npm-run-all -s build:development test:integration:local:safari:_execute",
"test:integration:local:all": "npm-run-all -s build:development test:integration:local:all:_execute",
"test:integration:local:_execute": "nightwatch -c ./integration-tests/utils/local.conf.js -e headlessChrome",
"test:integration:local:all:_execute": "nightwatch -c ./integration-tests/utils/local.conf.js -e headlessChrome,headlessFirefox,chrome,safari",
"test:integration:local:firefox:_execute": "nightwatch -c ./integration-tests/utils/local.conf.js -e firefox",
"test:integration:local:chrome:_execute": "nightwatch -c ./integration-tests/utils/local.conf.js -e chrome",
"test:integration:local:safari:_execute": "nightwatch -c ./integration-tests/utils/local.conf.js -e safari",
"test:integration:local:firefox:_execute": "nightwatch -c ./integration-tests/utils/local.conf.js -e firefox",
"test:integration:local:headlessChrome:_execute": "nightwatch -c ./integration-tests/utils/local.conf.js -e headlessChrome",
"test:integration:local:headlessFirefox:_execute": "nightwatch -c ./integration-tests/utils/local.conf.js -e headlessFirefox",
"test:integration:local:safari:_execute": "nightwatch -c ./integration-tests/utils/local.conf.js -e safari",
"test:integration:_selfSignCerts": "(cd utils && cd certs && openssl req -nodes -new -x509 -keyout server.key -out server.cert)",
"test:integration:_build": "npm-run-all -s build:*",
"test:performance": "node ./performance-tests/runner.js",
Expand Down

0 comments on commit 3d7bc86

Please sign in to comment.