Skip to content

Commit

Permalink
feat(e2e): add protractor scaffold to bangular
Browse files Browse the repository at this point in the history
  • Loading branch information
balthazar committed Mar 4, 2015
1 parent 0015c70 commit e4f3557
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 5 deletions.
24 changes: 19 additions & 5 deletions README.md
Expand Up @@ -26,12 +26,15 @@ Optional:

npm install -g generator-bangular
yo bangular

### Table of contents

- [Manage project](https://github.com/42Zavattas/generator-bangular#manage-project)
- [Generators](https://github.com/42Zavattas/generator-bangular#generators)
- [Features](https://github.com/42Zavattas/generator-bangular#features)
- [HOWTOs](https://github.com/42Zavattas/generator-bangular#howtos)
- [Protractor](https://github.com/42Zavattas/generator-bangular#protractor)
- [Sockets](https://github.com/42Zavattas/generator-bangular#sockets)
- [Passport](https://github.com/42Zavattas/generator-bangular#passport)
- [Architecture](https://github.com/42Zavattas/generator-bangular#architecutre)

# Manage project
Expand Down Expand Up @@ -60,6 +63,10 @@ Validate the app through JSHint.

Bump versions of `package.json` and `bower.json` files using *Semantic Versioning* and commit them. Default to **patch**.

gulp e2e

Launch your server and then run protractor tests. See [protractor howtos](https://github.com/42Zavattas/generator-bangular#protractor).

# Generators

- Global
Expand Down Expand Up @@ -143,7 +150,14 @@ The **name** parameter is required. This will create a new `.scss` file in he `c

The **name** parameter is required. A **name** folder will be created at `server/api/`.

# Features
# HOWTOs

### Protractor

First, you will have to run the `gulp e2e:update` command to update the chromedriver and the selenium jar.
Since the path to the jar is hardcoded in the `protractor.conf.js` file and the version is susceptible to change, you will potentially have to update the version number.
For people which have multiple Chrome installed, you can specify the path to the binary in the configuration.
You can now run `gulp e2e`, remember to stop your server since it will automatically create a new one.

### Sockets

Expand All @@ -158,8 +172,8 @@ The sockets can be quickly usable in your controllers, [here is an example](http

### Passport

On project generation, you can integrate passport authentification in your app. It will create default views for the signup and login. You can easily protect your routes for a connected user by adding the `isAuthenticated` middleware on it.

On project generation, you can integrate passport authentification in your app.
It will create default views for the signup and login. You can easily protect your routes for a connected user by adding the `isAuthenticated` middleware on it.

# Architecture

Expand Down
23 changes: 23 additions & 0 deletions app/templates/client/protractor.conf.js
@@ -0,0 +1,23 @@
exports.config = {

// The version is susceptible to change
seleniumServerJar: '../node_modules/gulp-protractor/node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar',
//chromeDriver: '../node_modules/gulp-protractor/node_modules/protractor/selenium/chromedriver',

baseUrl: 'http://localhost:9000',

capabilities: {
'browserName': 'chrome'
//'chromeOptions': {
// 'binary': '/usr/bin/google-chrome-unstable'
//}
},

framework: 'jasmine',

jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}

};
11 changes: 11 additions & 0 deletions app/templates/client/views/home/home.e2e.js
@@ -0,0 +1,11 @@
describe('home page', function () {

describe('basic', function () {
browser.get('/');

it('should have a basic content', function () {
expect(element.all(by.css('div')).first().getText()).toBe('HomeCtrl');
});
});

});
14 changes: 14 additions & 0 deletions app/templates/client/views/login(auth)/login.e2e.js
@@ -0,0 +1,14 @@
describe('login page', function () {

describe('basic', function () {
browser.get('/login');

it('should have two login inputs', function (done) {
element.all(by.css('input')).then(function (inputs) {
expect(inputs.length).toBe(2);
done();
});
});
});

});
14 changes: 14 additions & 0 deletions app/templates/client/views/signup(auth)/signup.e2e.js
@@ -0,0 +1,14 @@
describe('signup page', function () {

describe('basic', function () {
browser.get('/signup');

it('should have two signup inputs', function (done) {
element.all(by.css('input')).then(function (inputs) {
expect(inputs.length).toBe(2);
done();
});
});
});

});
20 changes: 20 additions & 0 deletions app/templates/gulpfile.js
Expand Up @@ -138,6 +138,26 @@ gulp.task('control', function () {
.pipe($.jshint.reporter('default'));
});


/**
* Protractor
*/
gulp.task('e2e:update', $.protractor.webdriver_update);

gulp.task('e2e', ['serve'], function () {
gulp.src('client/views/**/*.e2e.js')
.pipe($.protractor.protractor({
configFile: 'client/protractor.conf.js'
}))
.on('error', function (e) {
console.log(e);
process.exit(-1);
})
.on('end', function () {
process.exit(0);
});
});

/**
* Tests
*/
Expand Down
1 change: 1 addition & 0 deletions app/templates/package.json
Expand Up @@ -19,6 +19,7 @@
"gulp-nodemon": "^1.0.5",
"gulp-open": "^0.3.2",
"gulp-plumber": "^0.6.6",
"gulp-protractor": "^0.0.12",
"gulp-replace": "^0.5.2",
"gulp-rev-all": "^0.7.6",
"gulp-sass": "^1.3.2",
Expand Down
1 change: 1 addition & 0 deletions gulpfile.js
Expand Up @@ -21,6 +21,7 @@ gulp.task('logos', function (done) {
'logos/mongo.png',
'logos/sass.png',
'logos/karma.png',
'logos/protractor.png',
'logos/bower.png'
])
.pipe(spritesmith({
Expand Down
Binary file modified logos/logos-sprite.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logos/protractor.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e4f3557

Please sign in to comment.