Repository: couchdb-fauxton Updated Branches: refs/heads/2369a-Adding-Travis-tests-to-nightwatch [created] 0463ed908
Add nightwatch tests to work with Travis and Saucelabs Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/0463ed90 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/0463ed90 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/0463ed90 Branch: refs/heads/2369a-Adding-Travis-tests-to-nightwatch Commit: 0463ed9087e6e6ab10d78c313e84bd4f63adcabf Parents: 155d898 Author: Michelle Phung <[email protected]> Authored: Mon Nov 17 16:49:24 2014 -0500 Committer: Michelle Phung <[email protected]> Committed: Tue Nov 25 01:36:26 2014 -0500 ---------------------------------------------------------------------- .travis.yml | 19 ++- Gruntfile.js | 9 +- tasks/helper.js | 23 +++ .../custom-commands/loginToGUI.js | 8 +- test/nightwatch_tests/nightwatch.json | 152 +++++++++---------- 5 files changed, 127 insertions(+), 84 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0463ed90/.travis.yml ---------------------------------------------------------------------- diff --git a/.travis.yml b/.travis.yml index 2fba053..69e559d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,22 @@ language: node_js node_js: - - "0.10" +- '0.10' git: depth: 10 +services: +- couchdb +addons: + sauce_connect: true +before_install: +- HOST="http://127.0.0.1:5984" +- curl -X PUT $HOST/_config/admins/tester -d '"testerpass"' +before_script: +- npm install -g grunt-cli +- grunt dev & +- cat test/nightwatch_tests/nightwatch.json +script: +- grunt nightwatch_saucelabs +env: + global: + - secure: tFMWHR1UnXuIwFpJUSOtnUYMMZCmfr9UtlWj1waKNCOoB8QUEpgwddKzhXTP9BxBEpeCctcnqUz06L/ntvEX9rymJwifyy2YEel9knMdwFnscKQ963kUBBnjNFQRRo4Ea9lPdErJEAdSHYRlPUJIe7j2fanzsinneGNNW0jC7Hs= + - secure: sroHBeClUtMOEpqr6Lnedcy1AnKlYL7lW9S27h+VatTJDjzehCpsIVV7A4LuoIGUnMv+Jwn/lH9CukL99iztKXPImd6HYA2p/75pEgXsfSoyO93EU76FcGitVJuTc957pQw/4aOPbJpxvObJbT+D3xXdxNVkpekumrf4gvCfsDk= http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0463ed90/Gruntfile.js ---------------------------------------------------------------------- diff --git a/Gruntfile.js b/Gruntfile.js index 86ef8df..229d181 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -405,6 +405,10 @@ module.exports = function(grunt) { start_nightWatch: { command: __dirname + '/node_modules/nightwatch/bin/nightwatch' + ' -e chrome -c ' + __dirname + '/test/nightwatch_tests/' + 'nightwatch.json' + }, + start_nightWatch_saucelabs: { + command: __dirname + '/node_modules/nightwatch/bin/nightwatch' + + ' -e saucelabs -c ' + __dirname + '/test/nightwatch_tests/' + 'nightwatch.json' } }, @@ -429,6 +433,7 @@ module.exports = function(grunt) { var fileArg = grunt.option('file'); if (fileArg) { fileArg = fileArg + '.js'; + helper.getSourceDirectoriesForNightwatch(); var nightwatchConf = require('./test/nightwatch_tests/nightwatch.json'), paths; @@ -544,7 +549,9 @@ module.exports = function(grunt) { /* * Nightwatch functional testing */ + grunt.registerTask('write_nightwatch_json', helper.getSourceDirectoriesForNightwatch); //Start Nightwatch test from terminal, using: $ grunt nightwatch - grunt.registerTask('nightwatch', [ 'exec:check_selenium', 'selenium_start', 'exec:check_chrome_driver', 'exec:start_nightWatch']); + grunt.registerTask('nightwatch', [ 'write_nightwatch_json', 'exec:check_selenium', 'selenium_start', 'exec:check_chrome_driver', 'exec:start_nightWatch']); + grunt.registerTask('nightwatch_saucelabs', [ 'write_nightwatch_json', 'exec:start_nightWatch_saucelabs']); }; http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0463ed90/tasks/helper.js ---------------------------------------------------------------------- diff --git a/tasks/helper.js b/tasks/helper.js index 8da3b6b..401604f 100644 --- a/tasks/helper.js +++ b/tasks/helper.js @@ -43,6 +43,26 @@ exports.init = function(grunt) { }, defaults); }, + getSourceDirectoriesForNightwatch : function () { + var directories = [ + '**/nightwatch', + '!node_modules/nightwatch', + '!test/nightwatch_tests/reports/nightwatch' + ], + dir = [], + nightwatchDirectories = grunt.file.expand({filter: 'isDirectory'}, directories), + projectFile = "./test/nightwatch_tests/nightwatch.json", + project = grunt.file.readJSON(projectFile); //get file as json object + + if (!grunt.file.exists(projectFile)) { + grunt.log.error("file " + projectFile + " not found"); + return true; //return false to abort the execution + } + + project.src_folders = nightwatchDirectories; + grunt.file.write(projectFile, JSON.stringify(project, null, 2)+grunt.util.linefeed); //serialize it back to file + }, + check_selenium: { command: 'test -s ./test/nightwatch_tests/selenium/selenium-server-standalone-2.43.1.jar || curl -o ./test/nightwatch_tests/selenium/selenium-server-standalone-2.43.1.jar http://selenium-release.storage.googleapis.com/2.43/selenium-server-standalone-2.43.1.jar' }, @@ -69,6 +89,9 @@ exports.init = function(grunt) { type = 'linux32'; } break; + + default: + type = 'linux64'; } return 'test -s ./test/nightwatch_tests/selenium/chromedriver || (curl -o ./test/nightwatch_tests/selenium/chromedriver_'+type+'.zip http://chromedriver.storage.googleapis.com/2.9/chromedriver_'+type+'.zip && open ./test/nightwatch_tests/selenium/chromedriver_'+type+'.zip)'; http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0463ed90/test/nightwatch_tests/custom-commands/loginToGUI.js ---------------------------------------------------------------------- diff --git a/test/nightwatch_tests/custom-commands/loginToGUI.js b/test/nightwatch_tests/custom-commands/loginToGUI.js index ee2917c..d971f5e 100644 --- a/test/nightwatch_tests/custom-commands/loginToGUI.js +++ b/test/nightwatch_tests/custom-commands/loginToGUI.js @@ -5,13 +5,13 @@ exports.command = function () { client .url(baseUrl+'/#login') - .waitForElementPresent('a[href="#login"]', 8000, false) + .waitForElementPresent('a[href="#login"]', 15000, false) .click('a[href="#login"]') - .waitForElementPresent('#username', 8000, false) + .waitForElementPresent('#username', 10000, false) .setValue('#username', ['tester']) .setValue('#password', ['testerpass', client.Keys.ENTER]) .closeNotification() - .waitForElementPresent('#jump-to-db', 8000, false); - + .waitForElementPresent('#jump-to-db', 10000, false); + return this; }; http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/0463ed90/test/nightwatch_tests/nightwatch.json ---------------------------------------------------------------------- diff --git a/test/nightwatch_tests/nightwatch.json b/test/nightwatch_tests/nightwatch.json index 1f74596..f390df2 100644 --- a/test/nightwatch_tests/nightwatch.json +++ b/test/nightwatch_tests/nightwatch.json @@ -1,102 +1,98 @@ { - "src_folders" : [ - "./app/addons/databases/tests/nightwatch", - "./app/addons/documents/tests/nightwatch" - ], - "output_folder" : "./test/nightwatch_tests/reports", - "custom_commands_path" : "./test/nightwatch_tests/custom-commands", - "custom_assertions_path" : "", - "globals_path" : "./test/nightwatch_tests/helpers/helpers.js", - "live_output" : false, - - "selenium" : { - "start_process" : false, - "server_path" : "", - "log_path" : "", - "host" : "127.0.0.1", - "port" : 4444, - "cli_args" : { - "webdriver.chrome.driver" : "", - "webdriver.ie.driver" : "", - "webdriver.firefox.profile" : "" + "src_folders": [ + "app/addons/databases/tests/nightwatch", + "app/addons/documents/tests/nightwatch" + ], + "output_folder": "./test/nightwatch_tests/reports", + "custom_commands_path": "./test/nightwatch_tests/custom-commands", + "custom_assertions_path": "", + "globals_path": "./test/nightwatch_tests/helpers/helpers.js", + "live_output": false, + "selenium": { + "start_process": false, + "server_path": "", + "log_path": "", + "host": "127.0.0.1", + "port": 4444, + "cli_args": { + "webdriver.chrome.driver": "", + "webdriver.ie.driver": "", + "webdriver.firefox.profile": "" } }, - - "test_settings" : { - "default" : { - "launch_url" : "http://localhost", - "selenium_host" : "127.0.0.1", - "selenium_port" : 4444, - "silent" : true, + "test_settings": { + "default": { + "launch_url": "http://localhost", + "selenium_host": "127.0.0.1", + "selenium_port": 4444, + "silent": true, "disable_colors": false, - "screenshots" : { - "enabled" : false, - "path" : "" + "screenshots": { + "enabled": false, + "path": "" }, - "desiredCapabilities" : { - "browserName" : "firefox", - "javascriptEnabled" : true, - "acceptSslCerts" : true + "desiredCapabilities": { + "browserName": "firefox", + "javascriptEnabled": true, + "acceptSslCerts": true } }, - - "chrome" : { - "desiredCapabilities" : { - "browserName" : "chrome", - "javascriptEnabled" : true, - "acceptSslCerts" : true, - "chromeOptions" : { - "args" : ["window-size=1400,900"] + "chrome": { + "desiredCapabilities": { + "browserName": "chrome", + "javascriptEnabled": true, + "acceptSslCerts": true, + "chromeOptions": { + "args": [ + "window-size=1400,900" + ] } } }, - - - "saucelabs" : { - "selenium_host" : "ondemand.saucelabs.com", - "selenium_port" : 80, - "username" : "${SAUCE_USERNAME}", - "access_key" : "${SAUCE_ACCESS_KEY}", - "use_ssl" : false, - "silent" : true, - "output" : true, - "screenshots" : { - "enabled" : false, - "path" : "" + "saucelabs": { + "selenium_host": "ondemand.saucelabs.com", + "selenium_port": 80, + "username": "${SAUCE_USERNAME}", + "access_key": "${SAUCE_ACCESS_KEY}", + "use_ssl": false, + "silent": true, + "output": true, + "screenshots": { + "enabled": false, + "path": "" }, "desiredCapabilities": { - "name" : "test-example", - "browserName": "firefox" + "name": "test-example", + "browserName": "chrome", + "tunnel-identifier": "${TRAVIS_JOB_NUMBER}" }, - "globals" : { - "myGlobal" : "some_sauce_global" + "globals": { + "myGlobal": "some_sauce_global" }, - "selenium" : { - "start_process" : false + "selenium": { + "start_process": false } }, - - "phantomjs" : { - "desiredCapabilities" : { - "browserName" : "phantomjs", - "javascriptEnabled" : true, - "acceptSslCerts" : true, - "phantomjs.binary.path" : "/path/to/phantomjs" + "phantomjs": { + "desiredCapabilities": { + "browserName": "phantomjs", + "javascriptEnabled": true, + "acceptSslCerts": true, + "phantomjs.binary.path": "/path/to/phantomjs" } }, - - "browserstack" : { - "selenium" : { - "start_process" : false + "browserstack": { + "selenium": { + "start_process": false }, - "selenium_host" : "hub.browserstack.com", - "selenium_port" : 80, - "silent" : true, + "selenium_host": "hub.browserstack.com", + "selenium_port": 80, + "silent": true, "desiredCapabilities": { - "name" : "test-example", + "name": "test-example", "browserName": "firefox", - "browserstack.user" : "...", - "browserstack.key" : "..." + "browserstack.user": "...", + "browserstack.key": "..." } } }
