From 50ca41d21b71962e829bc2743cc37819c650dc41 Mon Sep 17 00:00:00 2001 From: Tyler Henkel Date: Sat, 20 Sep 2014 23:19:41 -0600 Subject: [PATCH] feat(generator): use sauce labs for running e2e tests with travis CI closes #572 --- .travis.yml | 6 ++++++ Gruntfile.js | 18 +++++++++++++----- app/templates/protractor.conf.js | 7 ++++--- endpoint/templates/index.spec.js | 4 ++-- test/test-file-creation.js | 24 +++++++++++------------- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 85fbe4a6b..ae5a22e65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,12 @@ language: node_js node_js: - '0.10' - '0.11' +env: + global: + - secure: fBqMlUrbIwaRJeKe39zxVsRcvtPIP/R98JNzrD0ycHzdfbhsWge0J7FCpdKjgRCf99ggqMhyevJafSJv7cfiVgJhB6kYudhG0G60V+vBjj4NIZnOelpVeQHXyLlekRpu+Qa/DaL43jovRAI0I11cwVfIRWtXZwiQOjCd/Elsdl8= + - secure: GZ95FcH0K88RG7P0SJjoIcHLfUalFRHeu5Vd7Kh0wXTh3O6Zku7iauk6Cd+aYGuFedL5wSzht5qnVBRm10VxhhJMxHiZ+I+VBxt4bysKM0axMZ+SMTfPK3zajVVXKfzIsIYO0m0qwYtHCgSXUrMnwAczESxczxq48VxA/rCXbYc= +addons: + sauce_connect: true before_install: - gem update --system - gem install sass --version "=3.3.7" diff --git a/Gruntfile.js b/Gruntfile.js index 9819a4041..3a510072a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,7 +3,7 @@ var markdown = require('marked'); var semver = require('semver'); var _s = require('underscore.string'); var shell = require('shelljs'); -var process = require('child_process'); +var child_process = require('child_process'); var Q = require('q'); var helpers = require('yeoman-generator').test; var fs = require('fs-extra'); @@ -227,12 +227,20 @@ module.exports = function (grunt) { shell.cd('test/fixtures'); grunt.log.ok('installing npm dependencies for generated app'); - process.exec('npm install --quiet', {cwd: '../fixtures'}, function (error, stdout, stderr) { + child_process.exec('npm install --quiet', {cwd: '../fixtures'}, function (error, stdout, stderr) { grunt.log.ok('installing bower dependencies for generated app'); - process.exec('bower install', {cwd: '../fixtures'}, function (error, stdout, stderr) { - shell.cd('../../'); - done(); + child_process.exec('bower install', {cwd: '../fixtures'}, function (error, stdout, stderr) { + + if(!process.env.SAUCE_USERNAME) { + child_process.exec('npm run update-webdriver', function() { + shell.cd('../../'); + done(); + }); + } else { + shell.cd('../../'); + done(); + } }) }); }); diff --git a/app/templates/protractor.conf.js b/app/templates/protractor.conf.js index cb66c67c1..d05f9e4d1 100644 --- a/app/templates/protractor.conf.js +++ b/app/templates/protractor.conf.js @@ -12,9 +12,10 @@ exports.config = { // with relative paths will be prepended with this. baseUrl: 'http://localhost:' + (process.env.PORT || '9000'), - // If true, only chromedriver will be started, not a standalone selenium. - // Tests for browsers other than chrome will not run. - chromeOnly: true, + // Credientials for Saucelabs + sauceUser: process.env.SAUCE_USERNAME, + + sauceKey: process.env.SAUCE_ACCESS_KEY, // list of files / patterns to load in the browser specs: [ diff --git a/endpoint/templates/index.spec.js b/endpoint/templates/index.spec.js index 031e379a4..fd1086b15 100644 --- a/endpoint/templates/index.spec.js +++ b/endpoint/templates/index.spec.js @@ -19,7 +19,7 @@ var routerStub = { }; // require the index with our stubbed out modules -var <%= name %>Index = proxyquire('./index.js', { +var <%= cameledName %>Index = proxyquire('./index.js', { 'express': { Router: function() { return routerStub; @@ -31,7 +31,7 @@ var <%= name %>Index = proxyquire('./index.js', { describe('<%= classedName %> API Router:', function() { it('should return an express router instance', function() { - <%= name %>Index.should.equal(router); + <%= cameledName %>Index.should.equal(routerStub); }); describe('GET <%= route %>', function() { diff --git a/test/test-file-creation.js b/test/test-file-creation.js index 05e83c77f..568315d92 100644 --- a/test/test-file-creation.js +++ b/test/test-file-creation.js @@ -149,7 +149,7 @@ describe('angular-fullstack generator', function () { 'server/api/thing/index.js', 'server/api/thing/index.spec.js', 'server/api/thing/thing.controller.js', - 'server/api/thing/thing.e2e.js', + 'server/api/thing/thing.integration.js', 'server/components/errors/index.js', 'server/config/local.env.js', 'server/config/local.env.sample.js', @@ -215,7 +215,7 @@ describe('angular-fullstack generator', function () { 'server/api/user/index.js', 'server/api/user/index.spec.js', 'server/api/user/user.controller.js', - 'server/api/user/user.e2e.js', + 'server/api/user/user.integration.js', 'server/api/user/user.model.js', 'server/api/user/user.model.spec.js', 'server/auth/index.js', @@ -347,17 +347,15 @@ describe('angular-fullstack generator', function () { }); }); -// it('should run e2e tests successfully', function(done) { -// this.timeout(80000); -// gen.run({}, function () { -// exec('npm run update-webdriver', function (error, stdout, stderr) { -// exec('grunt test:e2e', function (error, stdout, stderr) { -// expect(stdout, 'Client tests failed \n' + stdout ).to.contain('Done, without errors.'); -// done(); -// }); -// }); -// }) -// }); + it('should run e2e tests successfully', function(done) { + this.timeout(80000); + gen.run({}, function () { + exec('grunt test:e2e', function (error, stdout, stderr) { + expect(stdout, 'Client tests failed \n' + stdout).to.contain('0 failures'); + done(); + }); + }); + }); }); describe('with other preprocessors and oauth', function() {