Skip to content

Commit e8a0a8d

Browse files
committed
fix #4 use browser sync for e2e and embed phantomjs for protractor
1 parent b075504 commit e8a0a8d

File tree

6 files changed

+51
-29
lines changed

6 files changed

+51
-29
lines changed

app/templates/_package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030
"gulp-karma": "0.0.4",
3131
"karma-jasmine": "^0.1.5",
3232
"karma-phantomjs-launcher": "^0.1.4",
33-
"gulp-protractor": "0.0.7",
34-
"protractor": "~0.22.0",
3533
"require-dir": "~0.1.0",
3634
"browser-sync": "~0.9.1",
37-
"http-proxy": "~1.1.4"
35+
"http-proxy": "~1.1.4",
36+
"phantomjs": "~1.9.7-8",
37+
"protractor": "~0.24.0",
38+
"gulp-protractor": "0.0.7"
3839
},
3940
"engines": {
4041
"node": ">=0.10.0"

app/templates/gulp/e2e-tests.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,34 @@ var gulp = require('gulp');
44

55
var $ = require('gulp-load-plugins')();
66

7+
var browserSync = require('browser-sync');
8+
79
// Downloads the selenium webdriver
810
gulp.task('webdriver-update', $.protractor.webdriver_update);
911

1012
gulp.task('webdriver-standalone', $.protractor.webdriver_standalone);
1113

12-
gulp.task('protractor-only', ['webdriver-update', 'wiredep'], function(done) {
14+
gulp.task('protractor-only', ['webdriver-update', 'wiredep'], function (done) {
1315
var testFiles = [
1416
'test/e2e/**/*.js'
15-
]
17+
];
1618

1719
gulp.src(testFiles)
1820
.pipe($.protractor.protractor({
1921
configFile: 'test/protractor.conf.js',
2022
}))
21-
.on('error', function(err) {
23+
.on('error', function (err) {
2224
// Make sure failed tests cause gulp to exit non-zero
2325
throw err;
2426
})
25-
.on('end', function() {
27+
.on('end', function () {
2628
// Close connect server to and gulp connect task
27-
gulp.server.close();
29+
// Feature ignored because it's not possible to stop browser sync
30+
// browserSync.close();
2831
done();
2932
});
3033
});
3134

32-
gulp.task('protractor', ['connect:src', 'protractor-only']);
33-
gulp.task('protractor:src', ['connect:src', 'protractor-only']);
34-
gulp.task('protractor:dist', ['connect:dist', 'protractor-only']);
35+
gulp.task('protractor', ['serve:e2e', 'protractor-only']);
36+
gulp.task('protractor:src', ['serve:e2e', 'protractor-only']);
37+
gulp.task('protractor:dist', ['serve:e2e-dist', 'protractor-only']);

app/templates/gulp/server.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
var gulp = require('gulp');
44

5-
var $ = require('gulp-load-plugins')();
6-
75
var browserSync = require('browser-sync');
86
var httpProxy = require('http-proxy');
97

@@ -16,24 +14,28 @@ var proxy = httpProxy.createProxyServer({
1614
});
1715

1816
function proxyMiddleware(req, res, next) {
19-
if (req.url.indexOf(proxyApiPrefix) != -1) {
17+
if (req.url.indexOf(proxyApiPrefix) !== -1) {
2018
proxy.web(req, res);
2119
} else {
2220
next();
2321
}
24-
};
22+
}
23+
24+
function browserSyncInit(baseDir, files, browser) {
25+
browser = browser === undefined ? 'default' : browser;
2526

26-
function browserSyncInit(baseDir, files) {
2727
browserSync.init(files, {
28-
startPath: "/index.html",
28+
startPath: '/index.html',
2929
server: {
3030
baseDir: baseDir,
3131
middleware: proxyMiddleware
32-
}
32+
},
33+
browser: browser
3334
});
35+
3436
}
3537

36-
gulp.task('serve', ['watch'], function() {
38+
gulp.task('serve', ['watch'], function () {
3739
browserSyncInit([
3840
'app',
3941
'.tmp'
@@ -46,6 +48,14 @@ gulp.task('serve', ['watch'], function() {
4648
]);
4749
});
4850

49-
gulp.task('serve:dist', ['build'], function() {
51+
gulp.task('serve:dist', ['build'], function () {
5052
browserSyncInit('dist');
5153
});
54+
55+
gulp.task('serve:e2e', function () {
56+
browserSyncInit(['app', '.tmp'], null, []);
57+
});
58+
59+
gulp.task('serve:e2e-dist', ['watch'], function () {
60+
browserSyncInit('dist', null, []);
61+
});

app/templates/test/e2e/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
22

3-
describe('The main view', function(){
3+
describe('The main view', function () {
44

5-
beforeEach(function() {
6-
browser.get('http://localhost:9000');
5+
beforeEach(function () {
6+
browser.get('http://localhost:3002');
77
});
88

9-
it('list 3 awesome things', function() {
9+
it('list 3 awesome things', function () {
1010
expect(element.all(by.repeater('awesomeThing in awesomeThings')).count()).toBe(3);
1111
});
1212

app/templates/test/protractor.conf.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
exports.config = {
33
// The address of a running selenium server.
44
// seleniumAddress: 'http://localhost:4444/wd/hub',
5-
seleniumServerJar: '../node_modules/protractor/selenium/selenium-server-standalone-2.41.0.jar', // Make use you check the version in the folder
5+
seleniumServerJar: '../node_modules/protractor/selenium/selenium-server-standalone-2.42.0.jar', // Make use you check the version in the folder
66

77
// Capabilities to be passed to the webdriver instance.
88
capabilities: {
9-
'browserName': 'phantomjs'
9+
'browserName': 'phantomjs',
10+
11+
/*
12+
* Can be used to specify the phantomjs binary path.
13+
* This can generally be ommitted if you installed phantomjs globally.
14+
*/
15+
'phantomjs.binary.path': './node_modules/phantomjs/bin/phantomjs',
1016
},
1117

1218
// Spec patterns are relative to the current working directly when

test/deps/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@
2727
"gulp-karma": "^0.0.4",
2828
"karma-jasmine": "^0.1.5",
2929
"karma-phantomjs-launcher": "^0.1.4",
30-
"gulp-protractor": "0.0.7",
31-
"protractor": "~0.22.0",
3230
"require-dir": "~0.1.0",
3331
"gulp-ng-html2js": "~0.1.6",
3432
"gulp-minify-html": "~0.1.3",
3533
"gulp-inject": "~0.4.1",
3634
"browser-sync": "~0.9.1",
37-
"http-proxy": "~1.1.4"
35+
"http-proxy": "~1.1.4",
36+
"gulp-order": "~1.0.6",
37+
"phantomjs": "~1.9.7-8",
38+
"protractor": "~0.24.0",
39+
"gulp-protractor": "0.0.7"
3840
},
3941
"engines": {
4042
"node": ">=0.10.0"

0 commit comments

Comments
 (0)