From e7dae19d9fc6c66f4d849b4849c3b314fc301657 Mon Sep 17 00:00:00 2001 From: jacobawenger Date: Wed, 22 Oct 2014 15:10:45 -0700 Subject: [PATCH 1/6] Fixed broken test suite --- .travis.yml | 3 +++ gulpfile.js | 20 +++++++++++++++----- package.json | 4 +++- tests/karma-travis.conf.js | 27 +++++++++++++++++++++++++++ tests/karma.conf.js | 2 +- 5 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 tests/karma-travis.conf.js diff --git a/.travis.yml b/.travis.yml index 5fe83382..8fda8baa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ install: - npm install -g bower - npm install - bower install +before_script: +- export DISPLAY=:99.0 +- sh -e /etc/init.d/xvfb start script: - npm run travis after_script: diff --git a/gulpfile.js b/gulpfile.js index dbc9ca37..d5a10e34 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,7 +13,7 @@ var uglify = require("gulp-uglify"); var karma = require("gulp-karma"); // Determine if this is being run in Travis -var travis = (process.argv.indexOf('--travis') > -1); +var travis = false; /****************/ @@ -39,7 +39,10 @@ var paths = { }, tests: { - config: "tests/karma.conf.js", + configs: { + local: "tests/karma.conf.js", + travis: "tests/karam-travis.conf.js" + }, files: [ "bower_components/firebase/firebase.js", "tests/phantomjs-es5-shim.js", @@ -94,9 +97,10 @@ gulp.task("scripts", function() { /* Uses the Karma test runner to run the Jasmine tests */ gulp.task("test", function() { + var configFile = travis ? paths.tests.configs.travis : paths.tests.configs.local; return gulp.src(paths.tests.files) .pipe(karma({ - configFile: paths.tests.config, + configFile: configFile, action: "run" })) .on("error", function(error) { @@ -112,5 +116,11 @@ gulp.task("watch", function() { /* Builds the distribution files */ gulp.task("build", ["scripts"]); -/* Runs the "test" and "scripts" tasks by default */ -gulp.task("default", ["test", "scripts"]); \ No newline at end of file +/* Tasks to be run within Travis CI */ +gulp.task("travis", function() { + travis = true; + gulp.start("build", "test"); +}); + +/* Runs the "scripts" and "test" tasks by default */ +gulp.task("default", ["build", "test"]); diff --git a/package.json b/package.json index 2cbb07f1..c12c5a76 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,10 @@ "gulp-uglify": "^0.2.1", "jshint-stylish": "^0.2.0", "karma": "^0.12.16", + "karma-chrome-launcher": "^0.1.5", "karma-coverage": "^0.2.4", "karma-failed-reporter": "0.0.2", + "karma-firefox-launcher": "^0.1.3", "karma-jasmine": "~0.2.0", "karma-phantomjs-launcher": "~0.1.4", "karma-spec-reporter": "0.0.13", @@ -54,6 +56,6 @@ }, "scripts": { "test": "gulp test", - "travis": "gulp --travis" + "travis": "gulp travis" } } diff --git a/tests/karma-travis.conf.js b/tests/karma-travis.conf.js new file mode 100644 index 00000000..edc6ccf2 --- /dev/null +++ b/tests/karma-travis.conf.js @@ -0,0 +1,27 @@ +// Configuration file for Karma test runner +module.exports = function(config) { + config.set({ + frameworks: ["jasmine"], + browsers: ["Firefox"], + autowatch: false, + singleRun: true, + + preprocessors: { + "../src/*.js": "coverage" + }, + + reporters: ["spec", "failed", "coverage"], + coverageReporter: { + reporters: [ + { + type: "lcovonly", + dir: "coverage", + subdir: "." + }, + { + type: "text-summary" + } + ] + }, + }); +}; diff --git a/tests/karma.conf.js b/tests/karma.conf.js index bda72e7f..980b4968 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -2,7 +2,7 @@ module.exports = function(config) { config.set({ frameworks: ["jasmine"], - browsers: ["PhantomJS"], + browsers: ["Chrome"], autowatch: false, singleRun: true, From 8c2c93cb90f1389573d074cbb20e8f8e503abf96 Mon Sep 17 00:00:00 2001 From: jacobawenger Date: Wed, 22 Oct 2014 15:11:03 -0700 Subject: [PATCH 2/6] Removed unneeded comments in karma configuration files --- tests/karma-travis.conf.js | 1 - tests/karma.conf.js | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/karma-travis.conf.js b/tests/karma-travis.conf.js index edc6ccf2..6171f36b 100644 --- a/tests/karma-travis.conf.js +++ b/tests/karma-travis.conf.js @@ -1,4 +1,3 @@ -// Configuration file for Karma test runner module.exports = function(config) { config.set({ frameworks: ["jasmine"], diff --git a/tests/karma.conf.js b/tests/karma.conf.js index 980b4968..f1d61dad 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -1,4 +1,3 @@ -// Configuration file for Karma test runner module.exports = function(config) { config.set({ frameworks: ["jasmine"], From 100216a854e2131b921271e009555daed3bfb796 Mon Sep 17 00:00:00 2001 From: jacobawenger Date: Wed, 22 Oct 2014 15:14:15 -0700 Subject: [PATCH 3/6] Fixed typo in gulpfile --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index d5a10e34..7c53bdb7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -41,7 +41,7 @@ var paths = { tests: { configs: { local: "tests/karma.conf.js", - travis: "tests/karam-travis.conf.js" + travis: "tests/karma-travis.conf.js" }, files: [ "bower_components/firebase/firebase.js", From 61424f209219ef2f3e207ae24b0f0bef2fbd9cc4 Mon Sep 17 00:00:00 2001 From: jacobawenger Date: Wed, 22 Oct 2014 15:17:23 -0700 Subject: [PATCH 4/6] Cleaned up karma configuration files --- gulpfile.js | 9 +++------ tests/karma-travis.conf.js | 26 -------------------------- tests/karma.conf.js | 1 - 3 files changed, 3 insertions(+), 33 deletions(-) delete mode 100644 tests/karma-travis.conf.js diff --git a/gulpfile.js b/gulpfile.js index 7c53bdb7..0c66962d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -39,10 +39,7 @@ var paths = { }, tests: { - configs: { - local: "tests/karma.conf.js", - travis: "tests/karma-travis.conf.js" - }, + config: "tests/karma.conf.js", files: [ "bower_components/firebase/firebase.js", "tests/phantomjs-es5-shim.js", @@ -97,10 +94,10 @@ gulp.task("scripts", function() { /* Uses the Karma test runner to run the Jasmine tests */ gulp.task("test", function() { - var configFile = travis ? paths.tests.configs.travis : paths.tests.configs.local; return gulp.src(paths.tests.files) .pipe(karma({ - configFile: configFile, + configFile: paths.tests.config, + browsers: travis ? ["Firefox"] : ["Chrome"], action: "run" })) .on("error", function(error) { diff --git a/tests/karma-travis.conf.js b/tests/karma-travis.conf.js deleted file mode 100644 index 6171f36b..00000000 --- a/tests/karma-travis.conf.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = function(config) { - config.set({ - frameworks: ["jasmine"], - browsers: ["Firefox"], - autowatch: false, - singleRun: true, - - preprocessors: { - "../src/*.js": "coverage" - }, - - reporters: ["spec", "failed", "coverage"], - coverageReporter: { - reporters: [ - { - type: "lcovonly", - dir: "coverage", - subdir: "." - }, - { - type: "text-summary" - } - ] - }, - }); -}; diff --git a/tests/karma.conf.js b/tests/karma.conf.js index f1d61dad..884573df 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -1,7 +1,6 @@ module.exports = function(config) { config.set({ frameworks: ["jasmine"], - browsers: ["Chrome"], autowatch: false, singleRun: true, From b4909cc02f1e68141418df461f7a43af09a9bbb6 Mon Sep 17 00:00:00 2001 From: jacobawenger Date: Wed, 22 Oct 2014 22:55:33 -0700 Subject: [PATCH 5/6] Changed test Firebase to a production Firebase This fixed an issue running the test suite in Firefox --- package.json | 1 - tests/specs/common.spec.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index c12c5a76..189dfeb1 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "karma-failed-reporter": "0.0.2", "karma-firefox-launcher": "^0.1.3", "karma-jasmine": "~0.2.0", - "karma-phantomjs-launcher": "~0.1.4", "karma-spec-reporter": "0.0.13", "streamqueue": "^0.1.1" }, diff --git a/tests/specs/common.spec.js b/tests/specs/common.spec.js index 9c20d614..186fbb93 100644 --- a/tests/specs/common.spec.js +++ b/tests/specs/common.spec.js @@ -5,7 +5,7 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; // Get a reference to a random demo Firebase -var demoFirebaseUrl = "https://" + generateRandomString() + ".firebaseio-demo.com"; +var demoFirebaseUrl = "https://tests.firebaseio.com"; // React test addon var ReactTestUtils = React.addons.TestUtils; From 86d92620caa8104e11faa391d6e718a43ef37fc8 Mon Sep 17 00:00:00 2001 From: jacobawenger Date: Wed, 22 Oct 2014 23:01:35 -0700 Subject: [PATCH 6/6] Minor cleanup in common spec file --- tests/specs/common.spec.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/specs/common.spec.js b/tests/specs/common.spec.js index 186fbb93..5d12faa4 100644 --- a/tests/specs/common.spec.js +++ b/tests/specs/common.spec.js @@ -4,9 +4,6 @@ // Override the default timeout interval for Jasmine jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; -// Get a reference to a random demo Firebase -var demoFirebaseUrl = "https://tests.firebaseio.com"; - // React test addon var ReactTestUtils = React.addons.TestUtils; @@ -21,7 +18,7 @@ var invalidBindVars = ["", 1, true, false, [], {}, [1, 2], {a: 1}, null, undefin /* Helper function which runs before each Jasmine test has started */ function beforeEachHelper(done) { // Create a new firebase ref with a new context - firebaseRef = new Firebase(demoFirebaseUrl, Firebase.Context()); + firebaseRef = new Firebase("https://tests.firebaseio.com", Firebase.Context()); // Reset the Firebase firebaseRef.remove(function() {