From 154288808057ee50627630fe01c7b5fd272cabef Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 17 Oct 2017 19:34:55 +0700 Subject: [PATCH] yarn e2e-local is now e2e, add new yarn e2e-browserstack --- nightwatch-browserstack.conf.js | 39 +++++++++++++++++++++ nightwatch-local.conf.js | 50 --------------------------- nightwatch.conf.js | 61 +++++++++++++++++++-------------- package.json | 6 ++-- scripts/e2e-local.sh | 1 - 5 files changed, 78 insertions(+), 79 deletions(-) create mode 100644 nightwatch-browserstack.conf.js delete mode 100644 nightwatch-local.conf.js delete mode 100755 scripts/e2e-local.sh diff --git a/nightwatch-browserstack.conf.js b/nightwatch-browserstack.conf.js new file mode 100644 index 000000000..0f583673e --- /dev/null +++ b/nightwatch-browserstack.conf.js @@ -0,0 +1,39 @@ +const { + ROOT_URL +} = require('./config'); + +const nightwatch_config = { + src_folders: './test/e2e/specs/', + output_folder: './test/e2e/reports', + page_objects_path: './test/e2e/page_objects', + globals_path: './test/e2e/globals', + + selenium : { + start_process: false, + host: 'hub-cloud.browserstack.com', + port: 80 + }, + + test_settings: { + default: { + launch_url: ROOT_URL, + desiredCapabilities: { + 'browserstack.user': process.env.BROWSERSTACK_USER || 'coralproject2', + 'browserstack.key': process.env.BROWSERSTACK_KEY, + 'browserstack.local': true, + 'browserstack.debug': true, + 'browserstack.networkLogs': true, + 'browser': 'chrome', + } + } + } +}; + +// Code to copy seleniumhost/port into test settings +for(const i in nightwatch_config.test_settings){ + const config = nightwatch_config.test_settings[i]; + config['selenium_host'] = nightwatch_config.selenium.host; + config['selenium_port'] = nightwatch_config.selenium.port; +} + +module.exports = nightwatch_config; diff --git a/nightwatch-local.conf.js b/nightwatch-local.conf.js deleted file mode 100644 index 57034cdea..000000000 --- a/nightwatch-local.conf.js +++ /dev/null @@ -1,50 +0,0 @@ -const { - ROOT_URL -} = require('./config'); - -module.exports = { - src_folders: './test/e2e/specs/', - output_folder: './test/e2e/reports', - page_objects_path: './test/e2e/page_objects', - globals_path: './test/e2e/globals', - selenium: { - start_process: true, - server_path: 'node_modules/selenium-standalone/.selenium/selenium-server/3.5.3-server.jar', - log_path: './test/e2e/', - host: '127.0.0.1', - port: 6666, - cli_args: { - 'webdriver.chrome.driver': 'node_modules/selenium-standalone/.selenium/chromedriver/2.32-x64-chromedriver' - } - }, - test_settings: { - default: { - launch_url: ROOT_URL, - selenium_port: 6666, - selenium_host: 'localhost', - silent: true, - desiredCapabilities: { - browserName: 'chrome', - javascriptEnabled: true, - acceptSslCerts: true, - webStorageEnabled: true, - databaseEnabled: true, - applicationCacheEnabled: false, - nativeEvents: true, - }, - screenshots : { - enabled: true, - on_failure: true, - on_error: true, - path: './test/e2e/tests_output' - }, - }, - headless: { - desiredCapabilities: { - chromeOptions : { - args: ['--headless', '--disable-gpu'] - }, - }, - }, - }, -}; diff --git a/nightwatch.conf.js b/nightwatch.conf.js index 0f583673e..57034cdea 100644 --- a/nightwatch.conf.js +++ b/nightwatch.conf.js @@ -2,38 +2,49 @@ const { ROOT_URL } = require('./config'); -const nightwatch_config = { +module.exports = { src_folders: './test/e2e/specs/', output_folder: './test/e2e/reports', page_objects_path: './test/e2e/page_objects', globals_path: './test/e2e/globals', - - selenium : { - start_process: false, - host: 'hub-cloud.browserstack.com', - port: 80 + selenium: { + start_process: true, + server_path: 'node_modules/selenium-standalone/.selenium/selenium-server/3.5.3-server.jar', + log_path: './test/e2e/', + host: '127.0.0.1', + port: 6666, + cli_args: { + 'webdriver.chrome.driver': 'node_modules/selenium-standalone/.selenium/chromedriver/2.32-x64-chromedriver' + } }, - test_settings: { default: { launch_url: ROOT_URL, + selenium_port: 6666, + selenium_host: 'localhost', + silent: true, desiredCapabilities: { - 'browserstack.user': process.env.BROWSERSTACK_USER || 'coralproject2', - 'browserstack.key': process.env.BROWSERSTACK_KEY, - 'browserstack.local': true, - 'browserstack.debug': true, - 'browserstack.networkLogs': true, - 'browser': 'chrome', - } - } - } + browserName: 'chrome', + javascriptEnabled: true, + acceptSslCerts: true, + webStorageEnabled: true, + databaseEnabled: true, + applicationCacheEnabled: false, + nativeEvents: true, + }, + screenshots : { + enabled: true, + on_failure: true, + on_error: true, + path: './test/e2e/tests_output' + }, + }, + headless: { + desiredCapabilities: { + chromeOptions : { + args: ['--headless', '--disable-gpu'] + }, + }, + }, + }, }; - -// Code to copy seleniumhost/port into test settings -for(const i in nightwatch_config.test_settings){ - const config = nightwatch_config.test_settings[i]; - config['selenium_host'] = nightwatch_config.selenium.host; - config['selenium_port'] = nightwatch_config.selenium.port; -} - -module.exports = nightwatch_config; diff --git a/package.json b/package.json index 4ed063dc7..2137ac738 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,9 @@ "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": "NODE_ENV=test ./scripts/e2e.js", - "pree2e-local": "./scripts/e2e-local.sh", - "e2e-local": "NODE_ENV=test nightwatch --config nightwatch-local.conf.js", + "e2e-browserstack": "NODE_ENV=test ./scripts/e2e.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}", "test-cover": "TEST_MODE=unit NODE_ENV=test istanbul cover _mocha --report text --check-coverage -- -R spec", "heroku-postbuild": "./bin/cli plugins reconcile && yarn build", diff --git a/scripts/e2e-local.sh b/scripts/e2e-local.sh deleted file mode 100755 index 29874b971..000000000 --- a/scripts/e2e-local.sh +++ /dev/null @@ -1 +0,0 @@ -selenium-standalone install \ No newline at end of file