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

fixing grunt and gulp e2e tests #939

Merged
merged 1 commit into from
Oct 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ module.exports = function (grunt) {
options: {
configFile: 'protractor.conf.js',
keepAlive: true,
noColor: false
noColor: false,
webdriverManagerUpdate: true
},
e2e: {
options: {
Expand Down Expand Up @@ -274,9 +275,11 @@ module.exports = function (grunt) {
grunt.registerTask('build', ['env:dev', 'lint', 'ngAnnotate', 'uglify', 'cssmin']);

// Run the project tests
grunt.registerTask('test', ['env:test', 'lint', 'mkdir:upload', 'copy:localConfig', 'server', 'mochaTest', 'karma:unit']);
grunt.registerTask('test', ['env:test', 'lint', 'mkdir:upload', 'copy:localConfig', 'server', 'mochaTest', 'karma:unit', 'protractor']);
grunt.registerTask('test:server', ['env:test', 'lint', 'server', 'mochaTest']);
grunt.registerTask('test:client', ['env:test', 'lint', 'server', 'karma:unit']);
grunt.registerTask('test:e2e', ['env:test', 'lint', 'server', 'protractor']);

// Run project coverage
grunt.registerTask('coverage', ['env:test', 'lint', 'mocha_istanbul:coverage']);

Expand Down
38 changes: 28 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ var _ = require('lodash'),
}
}),
path = require('path'),
endOfLine = require('os').EOL;
endOfLine = require('os').EOL,
protractor = require("gulp-protractor").protractor,
webdriver_update = require("gulp-protractor").webdriver_update,
webdriver_standalone = require("gulp-protractor").webdriver_standalone;

// Set NODE_ENV to 'test'
gulp.task('env:test', function () {
Expand Down Expand Up @@ -195,17 +198,28 @@ gulp.task('karma', function (done) {
}));
});

// Selenium standalone WebDriver update task
gulp.task('webdriver-update', plugins.protractor.webdriver_update);
// Downloads the selenium webdriver
gulp.task('webdriver_update', webdriver_update);

// 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', function () {
gulp.task('protractor', ['webdriver_update'], function () {
gulp.src([])
.pipe(plugins.protractor.protractor({
.pipe(protractor({
configFile: 'protractor.conf.js'
}))
.on('error', function (e) {
throw e;
.on('end', function() {
console.log('E2E Testing complete');
// exit with success.
process.exit(0);
})
.on('error', function(err) {
console.log('E2E Tests failed');
process.exit(1);
});
});

Expand All @@ -221,15 +235,19 @@ gulp.task('build', function (done) {

// Run the project tests
gulp.task('test', function (done) {
runSequence('env:test', 'karma', 'mocha', done);
runSequence('env:test', 'lint', 'mocha', 'karma', 'nodemon', 'protractor', done);
});

gulp.task('test:server', function (done) {
runSequence('env:test', 'mocha', done);
runSequence('env:test', 'lint', 'mocha', done);
});

gulp.task('test:client', function (done) {
runSequence('env:test', 'karma', done);
runSequence('env:test', 'lint', 'karma', done);
});

gulp.task('test:e2e', function (done) {
runSequence('env:test', 'lint', 'nodemon', 'protractor', done);
});

// Run the project in development mode
Expand Down
2 changes: 1 addition & 1 deletion modules/articles/tests/e2e/articles.e2e.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe('Articles E2E Tests:', function () {
describe('Test articles page', function () {
it('Should report missing credentials', function () {
browser.get('http://localhost:3000/articles');
browser.get('http://localhost:3001/articles');
expect(element.all(by.repeater('article in articles')).count()).toEqual(0);
});
});
Expand Down
9 changes: 5 additions & 4 deletions modules/users/tests/e2e/users.e2e.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
describe('Users E2E Tests:', function () {
describe('Signin Validation', function () {
it('Should report missing credentials', function () {
browser.get('http://localhost:3000/authentication/signin');
browser.get('http://localhost:3001/authentication/signin');
element(by.css('button[type=submit]')).click();
element(by.binding('error')).getText().then(function (errorText) {
expect(errorText).toBe('Missing credentials');
});
// Username Error
expect(element.all(by.css('.error-text')).get(0).getText()).toBe('Username is required.');
// Password Error
expect(element.all(by.css('.error-text')).get(1).getText()).toBe('Password is required.');
});
});
});
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"validator": "^3.41.2"
},
"devDependencies": {
"coveralls": "^2.11.4",
"grunt-concurrent": "^2.0.0",
"grunt-contrib-copy": "~0.8.0",
"grunt-contrib-csslint": "~0.4.0",
Expand All @@ -76,12 +77,12 @@
"grunt-contrib-watch": "~0.6.1",
"grunt-env": "~0.4.4",
"grunt-karma": "~0.11.2",
"grunt-mocha-test": "~0.12.7",
"grunt-mocha-istanbul": "^2.4.0",
"grunt-mocha-test": "~0.12.7",
"grunt-ng-annotate": "^1.0.1",
"grunt-node-inspector": "~0.2.0",
"grunt-nodemon": "~0.4.0",
"grunt-protractor-runner": "^2.0.0",
"grunt-protractor-runner": "^2.1.0",
"gulp": "^3.9.0",
"gulp-angular-templatecache": "^1.7.0",
"gulp-autoprefixer": "^2.3.1",
Expand Down Expand Up @@ -111,7 +112,6 @@
"load-grunt-tasks": "^3.2.0",
"run-sequence": "^1.1.1",
"should": "^7.0.1",
"supertest": "^1.0.1",
"coveralls": "^2.11.4"
"supertest": "^1.0.1"
}
}