From 427c6e10a4dcb1dc654e72d51534e6b7cbaf236b Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 17 Oct 2017 21:38:50 +0700 Subject: [PATCH] Integrate browserstack into ci --- circle.yml | 2 +- nightwatch-browserstack.conf.js | 33 +++++++++++++++++++++++-- package.json | 3 ++- scripts/{e2e.js => e2e-browserstack.js} | 0 scripts/e2e-ci.sh | 23 +++++++++++++++++ 5 files changed, 57 insertions(+), 4 deletions(-) rename scripts/{e2e.js => e2e-browserstack.js} (100%) create mode 100755 scripts/e2e-ci.sh diff --git a/circle.yml b/circle.yml index 00e24ee89..4bbb2d946 100644 --- a/circle.yml +++ b/circle.yml @@ -47,7 +47,7 @@ test: override: # Run the tests using the junit reporter. - MOCHA_FILE=$CIRCLE_TEST_REPORTS/junit/test-results.xml MOCHA_REPORTER=mocha-junit-reporter yarn test - - yarn e2e -- --env chrome-headless + - yarn e2e-ci deployment: release: diff --git a/nightwatch-browserstack.conf.js b/nightwatch-browserstack.conf.js index 0f583673e..190bdad66 100644 --- a/nightwatch-browserstack.conf.js +++ b/nightwatch-browserstack.conf.js @@ -18,14 +18,43 @@ const nightwatch_config = { default: { launch_url: ROOT_URL, desiredCapabilities: { + browser: 'chrome', 'browserstack.user': process.env.BROWSERSTACK_USER || 'coralproject2', 'browserstack.key': process.env.BROWSERSTACK_KEY, 'browserstack.local': true, 'browserstack.debug': true, 'browserstack.networkLogs': true, - 'browser': 'chrome', } - } + }, + chrome: { + desiredCapabilities: { + browser: 'chrome', + }, + }, + firefox: { + desiredCapabilities: { + browser: 'firefox', + }, + }, + safari: { + desiredCapabilities: { + browser: 'safari', + }, + }, + ie: { + desiredCapabilities: { + browser: 'internet explorer', + + // Windows 10 seem to have troubles with the browserstackLocal tunnel (11.17.17). + os: 'Windows', + os_version: '8.1', + }, + }, + edge: { + desiredCapabilities: { + browser: 'edge', + }, + }, } }; diff --git a/package.json b/package.json index 2137ac738..29d26a131 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "lint": "yamllint locales/*.yml && eslint --ext=.js --ext=.json bin/* .", "lint-fix": "yarn lint --fix", "jest-watch": "TEST_MODE=unit NODE_ENV=test jest --watch", - "e2e-browserstack": "NODE_ENV=test ./scripts/e2e.js --config nightwatch-browserstack.conf.js", + "e2e-ci": "./scripts/e2e-ci.sh", + "e2e-browserstack": "NODE_ENV=test ./scripts/e2e-browserstack.js --config nightwatch-browserstack.conf.js", "pree2e": "selenium-standalone install", "e2e": "NODE_ENV=test nightwatch", "test": "TEST_MODE=unit NODE_ENV=test jest && TEST_MODE=unit NODE_ENV=test mocha -R ${MOCHA_REPORTER:-spec}", diff --git a/scripts/e2e.js b/scripts/e2e-browserstack.js similarity index 100% rename from scripts/e2e.js rename to scripts/e2e-browserstack.js diff --git a/scripts/e2e-ci.sh b/scripts/e2e-ci.sh new file mode 100755 index 000000000..01dcef5c5 --- /dev/null +++ b/scripts/e2e-ci.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +if [[ -z "${BROWSERSTACK_KEY}" ]]; then + # When browserstack is not available test locally using chrome headless. + yarn e2e -- --env chrome-headless +else + # Test using browserstack. + yarn e2e-browserstack -- --env chrome + sleep 2 + + yarn e2e-browserstack -- --env firefox + sleep 2 + + yarn e2e-browserstack -- --env safari + sleep 2 + + yarn e2e-browserstack -- --env ie + sleep 2 + + yarn e2e-browserstack -- --env edge +fi