From 080311e19bcd4d4f52eb2ab93a05765cc41f7484 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Fri, 12 Sep 2014 16:36:13 -0700 Subject: [PATCH] on travis, use grunt-saucelabs rather than phantomjs --- .travis.yml | 19 ++++++++++-------- package.json | 1 + tasks/config/saucelabs-mocha.js | 25 +++++++++++++++++++++++ tasks/test.js | 6 ++++-- test/unit/index.html | 34 ++++++++++++++++++++++++++++++++ test/unit/specs/vislib/y_axis.js | 18 ++++------------- 6 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 tasks/config/saucelabs-mocha.js diff --git a/.travis.yml b/.travis.yml index 523b2ed8bddb..34cfa7dfc447 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,23 @@ language: node_js node_js: - - '0.10' +- '0.10' install: - - npm install -g grunt-cli bower - - npm install - - bower install +- npm install -g grunt-cli bower +- npm install +- bower install script: - - npm test +- npm test notifications: email: - - rashid.khan@elasticsearch.com + - rashid.khan@elasticsearch.com hipchat: rooms: secure: a2FERvICecrUAR62vP4vrUCTG3haRzf6kSzDDzGu6SICEXWLRrK0xeNQDpdwDAfzFmaIJ6txpkmInvEFeNPYNngTgEDyfhqdIa/lW0Ermdg+1hL0dK6QJiVmT1V6LDB2mgtaTTmfontxJqq7P2tmr0zz8ny4Eqq3lUnwPxYFNNo= template: - - '%{repository}/%{branch} #%{build_number} by %{author}: %{message} (open)' + - '%{repository}/%{branch} #%{build_number} by %{author}: %{message} (open)' format: html on_success: change - on_failure: always \ No newline at end of file + on_failure: always +env: + global: + secure: AX9xidE0quyS07ZfOcecxEGjlNDT9YlM+fvtQHqOaODBII2jg5rgz0SyyxmTPSG68aqUNk8ML9slbRE4h0iPqNkB6fbDE2Dc6oTrRE7XFGDBjw66OHV2ZbsobdORf4UtWO06JBgLUEU2pzRYphe/B14dyA+ZO6p+bAgBmcdLd8k= diff --git a/package.json b/package.json index 2c451efb524a..5669d8dbfac1 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "grunt-mocha": "~0.4.10", "grunt-replace": "^0.7.9", "grunt-run": "^0.2.3", + "grunt-saucelabs": "~8.3.2", "http-proxy": "~1.1.4", "husky": "~0.6.0", "istanbul": "~0.2.4", diff --git a/tasks/config/saucelabs-mocha.js b/tasks/config/saucelabs-mocha.js new file mode 100644 index 000000000000..bdbc010092c3 --- /dev/null +++ b/tasks/config/saucelabs-mocha.js @@ -0,0 +1,25 @@ +module.exports = { + unit: { + options: { + urls: [ + 'http://localhost:8000/test/unit/' + ], + testname: 'Kibana Browser Tests', + build: process.env.TRAVIS_BUILD_ID || 'test build', + concurrency: 10, + username: 'kibana', + key: process.env.SAUCE_ACCESS_KEY, + browsers: [ + { + browserName: 'googlechrome', + platform: 'XP' + }, + { + browserName: 'internet explorer', + version: '10', + platform: 'Windows 7' + } + ] + } + } +}; \ No newline at end of file diff --git a/tasks/test.js b/tasks/test.js index 4a33ae775eb1..66e7f7720d2b 100644 --- a/tasks/test.js +++ b/tasks/test.js @@ -1,11 +1,13 @@ var _ = require('lodash'); module.exports = function (grunt) { - /* jshint scripturl:true */ + + var testTask = process.env.TRAVIS ? 'saucelabs-mocha:unit' : 'mocha:unit'; + grunt.registerTask('test', [ 'ruby_server', 'maybe_start_server', 'jade', - 'mocha:unit', + testTask, 'jshint' ]); diff --git a/test/unit/index.html b/test/unit/index.html index 9c7c8a720362..63acb81ae0eb 100644 --- a/test/unit/index.html +++ b/test/unit/index.html @@ -123,8 +123,42 @@ window.mochaRunner = mocha.run().on('end', function () { window.mochaResults = this.stats; + window.mochaResults.details = getFailedTests(this); xhr.restore(); }); + + function getFailedTests(runner) { + var fails = []; + var suiteStack = []; + + (function recurse(suite) { + suiteStack.push(suite); + + (suite.tests || []) + .filter(function (test) { + return test.state === 'failed'; + }) + .forEach(function (test) { + fails.push({ + title: suiteStack.reduce(function (title, suite) { + if (suite.title) { + return (title ? title + ' ' : '') + suite.title; + } else { + return title; + } + }, ''), + err: test.err ? (test.err.stack || test.err.message) : 'unknown error' + }); + }); + + (suite.suites || []).forEach(recurse); + + suiteStack.pop(); + }(runner.suite)); + + return fails; + } + }); }); } diff --git a/test/unit/specs/vislib/y_axis.js b/test/unit/specs/vislib/y_axis.js index 723d68e13a5b..c8343b90f3ef 100644 --- a/test/unit/specs/vislib/y_axis.js +++ b/test/unit/specs/vislib/y_axis.js @@ -178,22 +178,12 @@ define(function (require) { }); describe('render Method', function () { - beforeEach(function (done) { - var $node = $(yAxis.el); + beforeEach(function () { + expect(d3.select(yAxis.el).selectAll('.y-axis-div')).to.have.length(1); - this.timeout(30000); + [$(yAxis.el), $(yAxis.el).find('.y-axis-div')].forEach(debug); - (function check() { - if ($node.css('display') !== '-webkit-box') { - console.log('waiting for css to load'); - setTimeout(check, 1000); - } else { - expect(d3.select(yAxis.el).selectAll('.y-axis-div')).to.have.length(1); - [$(yAxis.el), $(yAxis.el).find('.y-axis-div')].forEach(debug); - yAxis.render(); - done(); - } - }()); + yAxis.render(); }); it('should append an svg to div', function () {