Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
fix(protractor): support for gulp-protractor for v6-7 only (#1752)
Browse files Browse the repository at this point in the history
* fix(protractor): updating gulp-protractor
* re-factoring out protractor prep tasks
  • Loading branch information
lirantal authored Apr 9, 2017
1 parent e5d7f15 commit 73135df
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 9 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ before_install:
- gem install sass --version "=3.3.7"
- npm i nsp -g
- npm i snyk -g
- npm install protractor
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- 'node_modules/protractor/bin/webdriver-manager update --standalone --firefox'
- 'node_modules/protractor/bin/webdriver-manager start 2>&1 &'
- export DISPLAY=:99.0
- bash scripts/setup-protractor.sh
- sleep 3
#before_script:
# - snyk auth $SNYK_TOKEN
Expand Down
47 changes: 44 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,23 @@ gulp.task('env:prod', function () {

// Nodemon task
gulp.task('nodemon', function () {

var nodeVersions = process.versions;
var debugArgument = '--debug';
switch (nodeVersions.node.substr(0, 1)) {
case '4':
case '5':
case '6':
debugArgument = '--debug';
break;
case '7':
debugArgument = '--inspect';
break;
}

return plugins.nodemon({
script: 'server.js',
nodeArgs: ['--inspect'],
nodeArgs: [debugArgument],
ext: 'js,html',
verbose: true,
watch: _.union(defaultAssets.server.views, defaultAssets.server.allJS, defaultAssets.server.config)
Expand Down Expand Up @@ -371,16 +385,43 @@ gulp.task('dropdb', function (done) {
});
});

// Downloads the selenium webdriver
// Downloads the selenium webdriver if protractor version is compatible
gulp.task('webdriver_update', webdriver_update);

gulp.task('webdriver_prep', function(done) {
runSequence('protractor_prep', 'webdriver_update', done);
});

gulp.task('protractor_prep', function() {
var nodeVersions = process.versions;
switch (nodeVersions.node.substr(0, 1)) {
case '4':
case '5':
console.log('E2E testing doesnt support v4 and v5');
process.exit(0);
break;
case '6':
if (parseInt(nodeVersions.node.substr(1, 1), 10) < 9) {
console.log('E2E testing with latest protractor requires v >= 6.9 ');
process.exit(0);
}
break;
default:
console.log('Detecting support for protractor E2E tests');
break;
}

return gulp.src('*.js');

This comment has been minimized.

Copy link
@mleanos

mleanos Apr 16, 2017

Member

Is there a specific reason for returning gulp.src('*.js') here?

A simple return; should suffice. It's a little confusing as to what this accomplishes, so it would probably be best to add a comment to why it's needed or remove it.

This comment has been minimized.

Copy link
@lirantal

lirantal Apr 17, 2017

Author Member

because seems like we must return a stream and can't just return null.
I think the next PR is going to remove all of this completely though because we don't need the v4 vs v6 anymore if we'll be supporting v6 and above anyway

});


// Start the standalone selenium server
// NOTE: This is not needed if you reference the
// seleniumServerJar in your protractor.conf.js
gulp.task('webdriver_standalone', webdriver_standalone);

// Protractor test runner task
gulp.task('protractor', ['webdriver_update'], function () {
gulp.task('protractor', ['webdriver_prep'], function () {
gulp.src([])
.pipe(protractor({
configFile: 'protractor.conf.js'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"gulp-mocha": "~3.0.1",
"gulp-ng-annotate": "~2.0.0",
"gulp-nodemon": "~2.2.1",
"gulp-protractor": "~3.0.0",
"gulp-protractor": "^3.0.0",
"gulp-refresh": "~1.1.0",
"gulp-rename": "~1.2.2",
"gulp-rev": "^7.1.2",
Expand Down
11 changes: 11 additions & 0 deletions scripts/setup-protractor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -x

echo "$TRAVIS_NODE_VERSION"
if [[ "$TRAVIS_NODE_VERSION" == "6" || "$TRAVIS_NODE_VERSION" == "7" ]]
then
npm install protractor
export DISPLAY=:99.0
bash -e /etc/init.d/xvfb start
./node_modules/protractor/bin/webdriver-manager update --standalone --firefox
./node_modules/protractor/bin/webdriver-manager start 2>&1 &
fi

0 comments on commit 73135df

Please sign in to comment.