From 1e767554f829299fe322808b43142d6863525f3d Mon Sep 17 00:00:00 2001 From: Jason Kirkpatrick Date: Fri, 12 Dec 2014 22:07:51 -0500 Subject: [PATCH 1/4] Setup travis and mocha --- .travis.yml | 9 +++++++++ CONTRIBUTING.md | 5 +++++ package.json | 8 +++++--- test/README.md | 4 ++++ test/test.js | 13 +++++++++++++ 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 .travis.yml create mode 100644 test/README.md create mode 100644 test/test.js diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..398361d --- /dev/null +++ b/.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 noop \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 870e48d..24d75eb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,6 +13,9 @@ This document describes how to contribute to Batarang ## Running the tests +1. Install from Source +2. Run mocha tests `npm run test` + ## Packaging a release I (@btford) will do this periodically, but I'm adding these instructions here @@ -33,4 +36,6 @@ The `panel` directory contains... ## Testing Batarang manually +Run `mocha` in the source code root directory. + diff --git a/package.json b/package.json index d57dd44..bb28abb 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,9 @@ "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" + "mocha": "^2.0.1" }, "dependencies": { "angular": "^1.3.6", @@ -19,8 +20,9 @@ "vinyl-source-stream": "^0.1.1" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build": "gulp" + "test": "mocha", + "build": "gulp", + "noop": "echo" }, "repository": { "type": "git", diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..3c92d8e --- /dev/null +++ b/test/README.md @@ -0,0 +1,4 @@ +## Travis CI test +Official (not yet setup) ![Travis-CI](https://travis-ci.org/angular/angularjs-batarang.svg) + +Unofficial (JK) ![Travis-CI](https://travis-ci.org/jkirkpatrick/angularjs-batarang.svg) diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..37eee18 --- /dev/null +++ b/test/test.js @@ -0,0 +1,13 @@ +"use strict"; + +//this is a test + +var assert = require("assert") + +describe('Dummy Suite', function(){ + describe('This project needs tests', function() { + it('Hintjs and Angularjs never break my dev enviorment (fake test)', function(){ + assert(true) + }) + }) +}) \ No newline at end of file From c49fcfba250083c70f091b9f79aa4a7873872077 Mon Sep 17 00:00:00 2001 From: Jason Kirkpatrick Date: Sat, 13 Dec 2014 00:39:28 -0500 Subject: [PATCH 2/4] removed mocha added protractor --- .travis.yml | 6 +++--- gulpfile.js | 15 +++++++++++++++ package.json | 7 ++++--- protractor.config.js | 19 +++++++++++++++++++ test/README.md | 4 ---- test/test.js | 13 ------------- tests/main.js | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 protractor.config.js delete mode 100644 test/README.md delete mode 100644 test/test.js create mode 100644 tests/main.js diff --git a/.travis.yml b/.travis.yml index 398361d..376f2bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ node_js: - "0.10" before_install: - npm config set ca "" -before_script: - - npm run-script noop +#before_script: +# - npm run-script noop after_success: - - npm run-script noop \ No newline at end of file + - npm run-script coverage \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index a454038..c3909c4 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,16 @@ 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('test', ['webdriver_update'], function() { + return gulp.src(["./tests/*.js"]) + .pipe(protractor({ + configFile: "protractor.config.js", + args: ['--baseUrl', 'http://127.0.0.1:8000'] + })) + .on('error', function(e) { throw e; }) +}); + gulp.task('default', ['browserify']); diff --git a/package.json b/package.json index bb28abb..30d5340 100644 --- a/package.json +++ b/package.json @@ -5,12 +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", - "mocha": "^2.0.1" + "protractor": "^1.5.0" }, "dependencies": { "angular": "^1.3.6", @@ -20,9 +21,9 @@ "vinyl-source-stream": "^0.1.1" }, "scripts": { - "test": "mocha", + "test": "gulp test", "build": "gulp", - "noop": "echo" + "coverage": "echo Coverage report not implemented && exit 0" }, "repository": { "type": "git", diff --git a/protractor.config.js b/protractor.config.js new file mode 100644 index 0000000..89e9dcb --- /dev/null +++ b/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/test/README.md b/test/README.md deleted file mode 100644 index 3c92d8e..0000000 --- a/test/README.md +++ /dev/null @@ -1,4 +0,0 @@ -## Travis CI test -Official (not yet setup) ![Travis-CI](https://travis-ci.org/angular/angularjs-batarang.svg) - -Unofficial (JK) ![Travis-CI](https://travis-ci.org/jkirkpatrick/angularjs-batarang.svg) diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 37eee18..0000000 --- a/test/test.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; - -//this is a test - -var assert = require("assert") - -describe('Dummy Suite', function(){ - describe('This project needs tests', function() { - it('Hintjs and Angularjs never break my dev enviorment (fake test)', function(){ - assert(true) - }) - }) -}) \ 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 From d8128763fcff9d144bd42092ac90e778abe9ab8d Mon Sep 17 00:00:00 2001 From: Jason Kirkpatrick Date: Sat, 13 Dec 2014 01:24:02 -0500 Subject: [PATCH 3/4] remove travis add multiple chrome profiles --- gulpfile.js | 12 ++++++++-- .travis.yml => ignore.travis.yml | 0 profiles/another.config.js | 24 +++++++++++++++++++ .../protractor.config.js | 2 +- 4 files changed, 35 insertions(+), 3 deletions(-) rename .travis.yml => ignore.travis.yml (100%) create mode 100644 profiles/another.config.js rename protractor.config.js => profiles/protractor.config.js (80%) diff --git a/gulpfile.js b/gulpfile.js index c3909c4..07470db 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -45,10 +45,18 @@ gulp.task('zip', ['package'], function () { // protractor and selenium gulp.task('webdriver_update', webdriver_update); gulp.task('webdriver_standalone', webdriver_standalone); -gulp.task('test', ['webdriver_update'], function() { +gulp.task('profile1', ['webdriver_update'], function() { return gulp.src(["./tests/*.js"]) .pipe(protractor({ - configFile: "protractor.config.js", + 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; }) diff --git a/.travis.yml b/ignore.travis.yml similarity index 100% rename from .travis.yml rename to ignore.travis.yml 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/protractor.config.js b/profiles/protractor.config.js similarity index 80% rename from protractor.config.js rename to profiles/protractor.config.js index 89e9dcb..13cfff8 100644 --- a/protractor.config.js +++ b/profiles/protractor.config.js @@ -4,7 +4,7 @@ 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 + 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: { From 9287bb687bc4c5fd26a1d4d4227b8cf2df31300b Mon Sep 17 00:00:00 2001 From: Jason Kirkpatrick Date: Sat, 13 Dec 2014 01:32:37 -0500 Subject: [PATCH 4/4] Added testing info to CONTRIBUTING --- CONTRIBUTING.md | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 24d75eb..ed43065 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,9 @@ This document describes how to contribute to Batarang ## Running the tests 1. Install from Source -2. Run mocha tests `npm run test` +2. `webdriver-manager update` +3. Run test (using default profile) `npm test` +4. Run test with another profile `gulp profile2` ## Packaging a release @@ -36,6 +38,6 @@ The `panel` directory contains... ## Testing Batarang manually -Run `mocha` in the source code root directory. +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/package.json b/package.json index 30d5340..01dd2d9 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "vinyl-source-stream": "^0.1.1" }, "scripts": { - "test": "gulp test", + "test": "gulp profile1", "build": "gulp", "coverage": "echo Coverage report not implemented && exit 0" },