diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 870e48d..ed43065 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,6 +13,11 @@ This document describes how to contribute to Batarang ## Running the tests +1. Install from Source +2. `webdriver-manager update` +3. Run test (using default profile) `npm test` +4. Run test with another profile `gulp profile2` + ## Packaging a release I (@btford) will do this periodically, but I'm adding these instructions here @@ -33,4 +38,6 @@ The `panel` directory contains... ## Testing Batarang manually +Run `gulp profile1` in the source code root directory to use the default chrome profile. Edit `profiles/another.profile.js` to point to your own chrome data directory then run `gulp profile2` + diff --git a/gulpfile.js b/gulpfile.js index a454038..07470db 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,6 +2,9 @@ var gulp = require('gulp'); var source = require('vinyl-source-stream'); var browserify = require('browserify'); var zip = require('gulp-zip'); +var protractor = require("gulp-protractor").protractor; +var webdriver_standalone = require("gulp-protractor").webdriver_standalone; +var webdriver_update = require("gulp-protractor").webdriver_update; var main = require('./package.json').main; // TODO: make sure manifest version === package.json version === bower.json version @@ -39,4 +42,24 @@ gulp.task('zip', ['package'], function () { .pipe(gulp.dest('.')); }); +// protractor and selenium +gulp.task('webdriver_update', webdriver_update); +gulp.task('webdriver_standalone', webdriver_standalone); +gulp.task('profile1', ['webdriver_update'], function() { + return gulp.src(["./tests/*.js"]) + .pipe(protractor({ + configFile: "profiles/protractor.config.js", + args: ['--baseUrl', 'http://127.0.0.1:8000'] + })) + .on('error', function(e) { throw e; }) +}); +gulp.task('profile2', ['webdriver_update'], function() { + return gulp.src(["./tests/*.js"]) + .pipe(protractor({ + configFile: "profiles/another.config.js", + args: ['--baseUrl', 'http://127.0.0.1:8000'] + })) + .on('error', function(e) { throw e; }) +}); + gulp.task('default', ['browserify']); diff --git a/ignore.travis.yml b/ignore.travis.yml new file mode 100644 index 0000000..376f2bd --- /dev/null +++ b/ignore.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - "0.10" +before_install: + - npm config set ca "" +#before_script: +# - npm run-script noop +after_success: + - npm run-script coverage \ No newline at end of file diff --git a/package.json b/package.json index d57dd44..01dd2d9 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,13 @@ "main": "hint.js", "devDependencies": { "angular-mocks": "^1.3.6", + "gulp-protractor": "0.0.12", "gulp-zip": "^2.0.2", "karma-bro": "^0.6.0", "karma-chrome-launcher": "^0.1.4", + "karma-jasmine": "^0.1.5", "karma-sauce-launcher": "^0.2.9", - "karma-jasmine": "^0.1.5" + "protractor": "^1.5.0" }, "dependencies": { "angular": "^1.3.6", @@ -19,8 +21,9 @@ "vinyl-source-stream": "^0.1.1" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build": "gulp" + "test": "gulp profile1", + "build": "gulp", + "coverage": "echo Coverage report not implemented && exit 0" }, "repository": { "type": "git", diff --git a/profiles/another.config.js b/profiles/another.config.js new file mode 100644 index 0000000..77dddd4 --- /dev/null +++ b/profiles/another.config.js @@ -0,0 +1,24 @@ +// An example configuration file. +// https://raw.github.com/angular/protractor/master/example/conf.js +exports.config = { + // The address of a running selenium server. + // if you get a permissions error, you can try this (warning: unsecure) + // chmod -R nobody: /usr/local/lib/node_modules/protractor/selenium + seleniumServerJar: '../node_modules/protractor/selenium/selenium-server-standalone-2.44.0.jar', // Make use you check the version in the folder + //seleniumAddress: 'http://localhost:4444/wd/hub', + // Capabilities to be passed to the webdriver instance. + capabilities: { + browserName: 'chrome', + chromeOptions: { + args: [ + '--user-data-dir=/home/jason/.config/chromium' + ] + } + }, + + // Options to be passed to Jasmine-node. + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000 + }, +}; \ No newline at end of file diff --git a/profiles/protractor.config.js b/profiles/protractor.config.js new file mode 100644 index 0000000..13cfff8 --- /dev/null +++ b/profiles/protractor.config.js @@ -0,0 +1,19 @@ +// An example configuration file. +// https://raw.github.com/angular/protractor/master/example/conf.js +exports.config = { + // The address of a running selenium server. + // if you get a permissions error, you can try this (warning: unsecure) + // chmod -R nobody: /usr/local/lib/node_modules/protractor/selenium + seleniumServerJar: '../node_modules/protractor/selenium/selenium-server-standalone-2.44.0.jar', // Make use you check the version in the folder + //seleniumAddress: 'http://localhost:4444/wd/hub', + // Capabilities to be passed to the webdriver instance. + capabilities: { + 'browserName': 'chrome' + }, + + // Options to be passed to Jasmine-node. + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000 + }, +}; \ No newline at end of file diff --git a/tests/main.js b/tests/main.js new file mode 100644 index 0000000..7fd0234 --- /dev/null +++ b/tests/main.js @@ -0,0 +1,38 @@ +// example test +describe('angularjs homepage', function() { + it('should greet the named user', function() { + browser.get('http://www.angularjs.org'); + + element(by.model('yourName')).sendKeys('Julie'); + + var greeting = element(by.binding('yourName')); + + expect(greeting.getText()).toEqual('Hello Julie!'); + }); + + describe('todo list', function() { + var todoList; + + beforeEach(function() { + browser.get('http://www.angularjs.org'); + + todoList = element.all(by.repeater('todo in todos')); + }); + + it('should list todos', function() { + expect(todoList.count()).toEqual(2); + expect(todoList.get(1).getText()).toEqual('build an angular app'); + }); + + it('should add a todo', function() { + var addTodo = element(by.model('todoText')); + var addButton = element(by.css('[value="add"]')); + + addTodo.sendKeys('write a protractor test'); + addButton.click(); + + expect(todoList.count()).toEqual(3); + expect(todoList.get(2).getText()).toEqual('write a protractor test'); + }); + }); +}); \ No newline at end of file