From 1ab7c564c08eb10b3730afcd7171b7ce5ac822aa Mon Sep 17 00:00:00 2001 From: heidilaursen Date: Wed, 25 May 2016 22:20:16 -0700 Subject: [PATCH 1/9] adding protractor again --- test/ang-spec.js | 9 +++++++++ test/config.js | 4 ++++ 2 files changed, 13 insertions(+) create mode 100644 test/ang-spec.js create mode 100644 test/config.js diff --git a/test/ang-spec.js b/test/ang-spec.js new file mode 100644 index 0000000..19b92f8 --- /dev/null +++ b/test/ang-spec.js @@ -0,0 +1,9 @@ ++describe('our super awesome angular app', function() { + + it('should have a 2 way data binding', () => { + + browser.get('http://localhost:4020'); + + element(by.model('greeting')).sendKeys('hello world'); + + element(by.id('greeting')).getText().then(function(text) { + + expect(text).toEqual('hello world'); + + }); + + }); + +}); diff --git a/test/config.js b/test/config.js new file mode 100644 index 0000000..c68464a --- /dev/null +++ b/test/config.js @@ -0,0 +1,4 @@ ++exports.config = { + + seleniumAddress: 'http://localhost:4444/wd/hub', + + specs: ['ang-spec.js'] + +}; From 89f0515141455afc29f8ad1d8d7dd3f035fa319c Mon Sep 17 00:00:00 2001 From: heidilaursen Date: Thu, 26 May 2016 14:01:57 -0700 Subject: [PATCH 2/9] setting up repo the way it was for 1st protractor test may 11 --- lib/basic_http.js | 21 --------------------- lib/errorHandler.js | 4 ---- lib/jwt_auth.js | 19 ------------------- models/rabbit.js | 9 --------- models/slug.js | 9 --------- router/rabbitRouter.js | 36 ------------------------------------ router/slugRouter.js | 36 ------------------------------------ 7 files changed, 134 deletions(-) delete mode 100644 lib/basic_http.js delete mode 100644 lib/errorHandler.js delete mode 100644 lib/jwt_auth.js delete mode 100644 models/rabbit.js delete mode 100644 models/slug.js delete mode 100644 router/rabbitRouter.js delete mode 100644 router/slugRouter.js diff --git a/lib/basic_http.js b/lib/basic_http.js deleted file mode 100644 index a50096b..0000000 --- a/lib/basic_http.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = exports = function(req, res, next) { - try { - var authHeader = req.headers.authorization; - var namePassword = authHeader.split(' ')[1]; - var namePassBuf = new Buffer(namePassword, 'base64'); - var namePassPT = namePassBuf.toString(); - namePassBuf.fill(0); - var namePassArr = namePassPT.split(':'); - req.auth = { - username: namePassArr[0], - password: namePassArr[1] - }; - if (req.auth.username.length < 1 || req.auth.password.length < 1) { - throw new Error('no username or password'); - } - } catch (e) { - console.log(e); - return res.status(418).json({ msg: 'not working' }); - } - next(); -}; diff --git a/lib/errorHandler.js b/lib/errorHandler.js deleted file mode 100644 index 426906e..0000000 --- a/lib/errorHandler.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = function(err, res) { - console.log(err); - res.status(500).json({ msg: 'server error' }); -}; diff --git a/lib/jwt_auth.js b/lib/jwt_auth.js deleted file mode 100644 index 6dda543..0000000 --- a/lib/jwt_auth.js +++ /dev/null @@ -1,19 +0,0 @@ -const User = require(__dirname + '/../models/user'); -const jwt = require('jsonwebtoken'); - -/*eslint-disable */ -module.exports = exports = function(req, res, next) { - jwt.verify(req.headers.token, process.env.APP_SECRET, function(err, decoded) { - if (err) return res.status(403).json({ msg: 'could not authenticat' }); - - User.findOne({ findHash: decoded.idd }, function(err, data) { - if (err) return res.status(403).json({ msg: 'could not authenticat' }); - - if (!data) return res.status(403).json({ msg: 'could not authenticat' }); - - req.user = data; - next(); - }); - }); -}; -/*eslint-enable */ diff --git a/models/rabbit.js b/models/rabbit.js deleted file mode 100644 index c654586..0000000 --- a/models/rabbit.js +++ /dev/null @@ -1,9 +0,0 @@ -const mongoose = require('mongoose'); - -var rabbitSchema = new mongoose.Schema({ - name: { type: String, unique: true }, - variety: { type: String }, - food: { type: String, default: 'parsley' } -}); - -module.exports = exports = mongoose.model('Rabbit', rabbitSchema); diff --git a/models/slug.js b/models/slug.js deleted file mode 100644 index b017453..0000000 --- a/models/slug.js +++ /dev/null @@ -1,9 +0,0 @@ -const mongoose = require('mongoose'); - -var slugSchema = new mongoose.Schema({ - name: { type: String, unique: true }, - variety: { type: String }, - food: { type: String, default: 'spinach' } -}); - -module.exports = exports = mongoose.model('Slug', slugSchema); diff --git a/router/rabbitRouter.js b/router/rabbitRouter.js deleted file mode 100644 index 2a86a86..0000000 --- a/router/rabbitRouter.js +++ /dev/null @@ -1,36 +0,0 @@ -const Router = require('express').Router; -const Rabbit = require(__dirname + '/../models/rabbit'); -const bodyParser = require('body-parser').json(); -const serverErrorHandler = require(__dirname + '/../lib/errorHandler'); -const rabbitRouter = module.exports = new Router(); - -rabbitRouter.post('/rabbits', bodyParser, (req, res) => { - var newRabbit = new Rabbit(req.body); - newRabbit.save((err, data) => { - if (err) return serverErrorHandler(err, res); - res.status(200).json(data); - }); -}); - -rabbitRouter.get('/rabbits', (req, res) => { - Rabbit.find({}, (err, data) => { - if (err) return serverErrorHandler(err, res); - res.status(200).json(data); - }); -}); - -rabbitRouter.put('/rabbits/:id', bodyParser, (req, res) => { - var rabbitData = req.body; - delete rabbitData._id; - Rabbit.update({ _id: req.params.id }, rabbitData, (err, data) => { - if (err) return serverErrorHandler(err, res); - res.status(200).json(data); - }); -}); - -rabbitRouter.delete('/rabbits/:id', (req, res) => { - Rabbit.remove({ _id: req.params.id }, (err) => { - if (err) return serverErrorHandler(err, res); - res.status(200).json({ msg: 'the rabbits gone' }); - }); -}); diff --git a/router/slugRouter.js b/router/slugRouter.js deleted file mode 100644 index 3eb3fd4..0000000 --- a/router/slugRouter.js +++ /dev/null @@ -1,36 +0,0 @@ -const Router = require('express').Router; -const Slug = require(__dirname + '/../models/slug'); -const bodyParser = require('body-parser').json(); -const serverErrorHandler = require(__dirname + '/../lib/errorHandler'); -const slugRouter = module.exports = new Router(); - -slugRouter.post('/slugs', bodyParser, (req, res) => { - var newSlug = new Slug(req.body); - newSlug.save((err) => { - if (err) return serverErrorHandler(err, res); - res.status(200).json({ msg: 'great job!' }); - }); -}); - -slugRouter.get('/slugs', (req, res) => { - Slug.find(null, (err, data) => { - if (err) return serverErrorHandler(err, res); - res.status(200).json(data); - }); -}); - -slugRouter.put('/slugs/:id', bodyParser, (req, res) => { - var slugData = req.body; - delete slugData._id; - Slug.update({ _id: req.params.id }, slugData, (err, data) => { - if (err) return serverErrorHandler(err, res); - res.status(200).json(data); - }); -}); - -slugRouter.delete('/slugs/:id', (req, res) => { - Slug.remove({ _id: req.params.id }, (err) => { - if (err) return serverErrorHandler(err, res); - res.status(200).json({ msg: 'the slugs are gone' }); - }); -}); From 128b16ec389916154d6980a511ee73bd2b48692c Mon Sep 17 00:00:00 2001 From: heidilaursen Date: Thu, 26 May 2016 14:04:52 -0700 Subject: [PATCH 3/9] rolling back repo to previous version from old protractor assignment --- app/index.html | 66 ++++++------------------------------------------- app/js/entry.js | 65 +----------------------------------------------- gulpfile.js | 47 ++++++++++------------------------- 3 files changed, 22 insertions(+), 156 deletions(-) diff --git a/app/index.html b/app/index.html index e9966d6..f3067ac 100644 --- a/app/index.html +++ b/app/index.html @@ -1,64 +1,14 @@ - + - - Slug and Rabbit dance off! - + + Stuff + - - -
- -
    -
  • - {{slug.name}}, {{slug.type}}, eats: {{slug.food}} - -
    - - - - - - - - - - - -
    - -
  • -
- -
- -
- -
    -
  • - {{rabbit.name}}, {{rabbit.type}}, eats: {{rabbit.food}} - -
    - - - - - - - - - - - -
    - -
  • -
- -
- - + +

{{greeting}}

+ + - diff --git a/app/js/entry.js b/app/js/entry.js index b228897..ee3a083 100644 --- a/app/js/entry.js +++ b/app/js/entry.js @@ -1,65 +1,2 @@ const angular = require('angular'); -const myApp = angular.module('myApp', []); -const baseUrl = 'http://localhost:5000'; - -var handleErrors = function(error) { - console.log(error); - this.errors = (this.errors || []).push(error); -}; - -myApp.controller('SlugController', ['$http', function($http) { - this.slug = []; - this.getAll = () => { - $http.get(baseUrl + '/api/slugs') - .then((res) => { - this.slug = res.data; - }, handleErrors.bind(this)); - }; - - this.createSlug = () => { - $http.post(baseUrl + '/api/slugs', this.newSlug) - .then((res) => { - this.slug.push(res.data); - this.newSlug = null; - }, handleErrors.bind(this)); - }; - - this.updateSlug = (slug) => { - $http.put(baseUrl + '/api/slugs' + slug._id, slug) - .then(() => { - slug.editing = false; - }, handleErrors.bind(this)); - }; -}]); - -myApp.controller('RabbitController', ['$http', function($http) { - this.rabbit = []; - this.getAll = () => { - $http.get(baseUrl + '/api/rabbits') - .then((res) => { - this.rabbit = res.data; - }, handleErrors.bind(this)); - }; - - this.createRabbit = () => { - $http.post(baseUrl + '/api/rabbits', this.newRabbit) - .then((res) => { - this.rabbit.push(res.data); - this.newRabbit = null; - }, handleErrors.bind(this)); - }; - - this.updateRabbit = (rabbit) => { - $http.put(baseUrl + '/api/rabbits' + rabbit._id, rabbit) - .then(() => { - this.rabbit.splice(this.rabbit.indexOf(rabbit), 1); - }, handleErrors.bind(this)); - }; - - this.deleteRabbit = (rabbit) => { - $http.delete(baseUrl + '/api/rabbits/' + rabbit._id) - .then(() => { - this.rabbit.splice(this.rabbit.indexOf(rabbit), 1); - }, handleErrors.bind(this)); - }; -}]); +const demoApp = angular.module('demoApp', []); diff --git a/gulpfile.js b/gulpfile.js index 285408b..b7ef538 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,33 +1,8 @@ -var gulp = require('gulp'); -var eslint = require('gulp-eslint'); -var webpack = require('webpack-stream'); +const gulp = require('gulp'); +const webpack = require('webpack-stream'); -var path = { - scripts: ['client_server.js', 'index.js', 'router/**/*.js', -'models/**/*.js', 'gulpfile.js'], - tests: [__dirname + '/test/server-test.js'], - client: ['app/js/entry.js'] -}; - -gulp.task('lintServer', () => { - return gulp.src(path.scripts) - .pipe(eslint({ - envs: [ - 'mocha', - 'es6' - ] - })) - .pipe(eslint.format()); -}); - -gulp.task('lintClient', () => { - return gulp.src(path.client) - .pipe(eslint('./app/.eslintrc')) - .pipe(eslint.format()); -}); - -gulp.task('entry', () => { - return gulp.src('app/js/entry.js') +gulp.task('webpack:dev', () => { + gulp.src('./app/js/entry.js') .pipe(webpack({ output: { filename: 'bundle.js' @@ -36,11 +11,15 @@ gulp.task('entry', () => { .pipe(gulp.dest('./build')); }); -gulp.task('html', () => { - return gulp.src('app/**/*.html') +gulp.task('static:dev', () => { + gulp.src('app/**/*.html') + .pipe(gulp.dest('./build')); +}); + +gulp.task('css:dev', () => { + gulp.src('app/css/*.css') .pipe(gulp.dest('./build')); }); -gulp.task('lint', ['lintServer', 'lintClient']); -gulp.task('build', ['entry', 'html']); -gulp.task('default', ['build', 'lint']); +gulp.task('default', ['webpack:dev', 'static:dev', 'css:dev']); +gulp.task('build:dev', ['webpack:dev', 'static:dev', 'css:dev']); From 96e336b9481f8ae7a23bd440a25fab7a0eac9a68 Mon Sep 17 00:00:00 2001 From: heidilaursen Date: Thu, 26 May 2016 14:08:41 -0700 Subject: [PATCH 4/9] rolling back server to may 11 --- client_server.js | 2 -- index.js | 2 -- server.js | 26 +------------------------- 3 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 client_server.js delete mode 100644 index.js diff --git a/client_server.js b/client_server.js deleted file mode 100644 index cd51cc2..0000000 --- a/client_server.js +++ /dev/null @@ -1,2 +0,0 @@ -const express = require('express'); -express().use(express.static(__dirname + '/build')).listen(5000, () => console.log('server up')); diff --git a/index.js b/index.js deleted file mode 100644 index 8ced9a3..0000000 --- a/index.js +++ /dev/null @@ -1,2 +0,0 @@ -require(__dirname + '/server.js'); -require(__dirname + '/client_server.js'); diff --git a/server.js b/server.js index 4cdef26..2015f70 100644 --- a/server.js +++ b/server.js @@ -1,25 +1 @@ -const express = require('express'); -const app = express(); -const PORT = process.env.PORT || 3000; -const rabbitRouter = require(__dirname + '/router/rabbitRouter'); -const slugRouter = require(__dirname + '/router/slugRouter'); -const mongoose = require('mongoose'); - -mongoose.connect(process.env.MONGO_URI || 'mongodb://localhost/slug_rabbit_db'); - -app.use('/api', rabbitRouter); -app.use('/api', slugRouter); - -module.exports = exports = { - server: { close: function() { throw new Error('server not started yet'); } }, - listen: function(port, mongoString, cb) { - mongoose.connect(mongoString); - return this.server = app.listen(port, cb); - }, - close: function(cb) { - this.server.close(); - if (cb) cb(); - } -}; - -app.listen(PORT, () => {console.log('server up on ' + PORT);}); +const express = require('express')().use(require('express').static(__dirname + '/build')).listen(4020, () => { console.log('server up'); }); From 61aefac61c0d9a2278f3b8adc474b4392079f7b9 Mon Sep 17 00:00:00 2001 From: heidilaursen Date: Thu, 26 May 2016 14:16:36 -0700 Subject: [PATCH 5/9] test is passing, again, yay --- package.json | 37 ++++++++----------------------------- test/ang-spec.js | 18 +++++++++--------- test/config.js | 8 ++++---- 3 files changed, 21 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index d92fbb2..25147b4 100644 --- a/package.json +++ b/package.json @@ -1,41 +1,20 @@ { - "name": "heidilaursen", + "name": "week_6", "version": "1.0.0", - "description": "Express api with REST and two Mongo databases. ", - "main": "node index.js", - "directories": { - "test": "test" - }, + "description": "", + "main": "gulpfile.js", "scripts": { - "test": " ./node_modules/mocha/bin/mocha test", - "start": "node index.js'" - }, - "repository": { - "type": "git", - "url": "https://github.com/pnwlady/rest_api.git" + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node server.js" }, - "keywords": [ - "REST", - "Express", - "Mongodb" - ], - "author": "Heidi Laursen", + "author": "", "license": "MIT", - "bugs": { - "url": "https://github.com/pnwlady/rest_api/issues" - }, - "homepage": "https://github.com/pnwlady/rest_api#readme", "dependencies": { - "body-parser": "^1.15.0", "express": "^4.13.4", - "mongodb": "^2.1.16", - "mongoose": "^4.4.13" + "webpack-stream": "^3.2.0" }, "devDependencies": { "angular": "^1.5.5", - "gulp": "^3.9.1", - "gulp-eslint": "^2.0.0", - "gulp-protractor": "^2.3.0", - "webpack-stream": "^3.2.0" + "gulp": "^3.9.1" } } diff --git a/test/ang-spec.js b/test/ang-spec.js index 19b92f8..eb6e9f2 100644 --- a/test/ang-spec.js +++ b/test/ang-spec.js @@ -1,9 +1,9 @@ -+describe('our super awesome angular app', function() { - + it('should have a 2 way data binding', () => { - + browser.get('http://localhost:4020'); - + element(by.model('greeting')).sendKeys('hello world'); - + element(by.id('greeting')).getText().then(function(text) { - + expect(text).toEqual('hello world'); - + }); - + }); - +}); +describe('our super awesome angular app', function() { + it('should have a 2 way data binding', () => { + browser.get('http://localhost:4020'); + element(by.model('greeting')).sendKeys('hello world'); + element(by.id('greeting')).getText().then(function(text) { + expect(text).toEqual('hello world'); + }); + }); +}); diff --git a/test/config.js b/test/config.js index c68464a..465d79c 100644 --- a/test/config.js +++ b/test/config.js @@ -1,4 +1,4 @@ -+exports.config = { - + seleniumAddress: 'http://localhost:4444/wd/hub', - + specs: ['ang-spec.js'] - +}; +exports.config = { + seleniumAddress: 'http://localhost:4444/wd/hub', + specs: ['ang-spec.js'] +}; From ce74afcc21b9cfd6cdb831f7c0711f1bd0c637c1 Mon Sep 17 00:00:00 2001 From: heidilaursen Date: Thu, 26 May 2016 14:28:41 -0700 Subject: [PATCH 6/9] updated read me for testing instructions --- README.md | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index d13bb22..5fef4f5 100644 --- a/README.md +++ b/README.md @@ -11,31 +11,22 @@ Two Mongoose Schema models are created (resources) to route and manipulate throu ##Dev dependencies * Gulp * Gulp-Eslint + * Webpack-stream -### How to Use -Run mongo ```mongod --dbpath=./db +### How to test with protractor and selenium +In the first terminal: ``` -Run ```node index -``` to start the client and backend servers. -Go to ```localhost:5000``` - -## Slugs and Rabbits -Enter Name, Type and Food in the test fields and click the update Slug or update Rabbit buttons. - -New entry will display in url. -Example: -```http://localhost:5000/?name=Sven&type=black&food=leaf +webdriver-manager start ``` - -### Database -See slugs by posting to localhost:4020/api/slugs - -The databases is located at ```localhost:4020 +In a second terminal: ``` - -```/api/rabbits -``` and ```/api/slugs +node server.js ``` - -The angular app is located at ```localhost:5000 +In a third terminal: +``` +gulp +``` +Run test with: +``` +protractor ./test/config.js ``` From b9c28152db7284291c43f507cc8abdc859bbdb93 Mon Sep 17 00:00:00 2001 From: heidilaursen Date: Sun, 5 Jun 2016 19:00:55 -0700 Subject: [PATCH 7/9] fixing tests - running selinium and server from start --- gulpfile.js | 44 ++++++++++++++++++++++++++++++++++++++++++-- package.json | 8 +++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index b7ef538..4f0c81c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,11 @@ const gulp = require('gulp'); const webpack = require('webpack-stream'); +const nodemon = require('gulp-nodemon'); +const cp = require('child_process'); +const exec = require('child_process').exec; +const protractor = require('gulp-protractor').protractor; +const mongoUri = 'mongodb://localhost/4020'; +var children = []; gulp.task('webpack:dev', () => { gulp.src('./app/js/entry.js') @@ -21,5 +27,39 @@ gulp.task('css:dev', () => { .pipe(gulp.dest('./build')); }); -gulp.task('default', ['webpack:dev', 'static:dev', 'css:dev']); -gulp.task('build:dev', ['webpack:dev', 'static:dev', 'css:dev']); +gulp.task('startservers:test', ['webpack:dev', 'static:dev', 'css:dev'], () => { + children.push(cp.fork('server.js')); + children.push(cp.spawn('webdriver-manager', ['start'])); + children.push(cp.spawn('mongod', ['--dbpath=./db'])); + children.push(cp.fork('../', [], {env: {MONGO_URI: mongoUri}})); +}); + +// gulp.task('startServers:develop', ['webpack:dev', 'static:dev', 'css:dev'], () => { +// nodemon({ +// script: 'server.js', +// ext: 'html js css', +// ignore: ['build'], +// tasks: ['protractor'] +// }); +// }); + +// gulp.task('startServers:selenium', () => { +// exec('webdriver-manager start', (cb) => { +// cb(err); +// }); +// }); + +gulp.task('protractor', ['startservers:test'], () => { + gulp.src(['./test/*spec.js']) + .pipe(protractor({ + configFile: 'test/config.js', + args: ['--baseUrl', 'http:127.0.0.1:5000'] + })) + .on('end', () => { + children.forEach((child) => { + child.kill('SIGTERM'); + }); + }); +}); + +gulp.task('default', ['protractor']); diff --git a/package.json b/package.json index 25147b4..9f4ef4d 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,13 @@ "author": "", "license": "MIT", "dependencies": { - "express": "^4.13.4", - "webpack-stream": "^3.2.0" + "express": "^4.13.4" }, "devDependencies": { "angular": "^1.5.5", - "gulp": "^3.9.1" + "gulp": "^3.9.1", + "gulp-nodemon": "^2.0.7", + "gulp-protractor": "^2.4.0", + "webpack-stream": "^3.2.0" } } From 56421462ab9ddf1422ff916cbf1ec70546994978 Mon Sep 17 00:00:00 2001 From: heidilaursen Date: Sun, 5 Jun 2016 19:11:15 -0700 Subject: [PATCH 8/9] fixed server for backend --- gulpfile.js | 4 ++-- test/ang-spec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 4f0c81c..7895fa8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,7 +4,7 @@ const nodemon = require('gulp-nodemon'); const cp = require('child_process'); const exec = require('child_process').exec; const protractor = require('gulp-protractor').protractor; -const mongoUri = 'mongodb://localhost/4020'; +const mongoUri = 'mongodb://localhost/test_server'; var children = []; gulp.task('webpack:dev', () => { @@ -31,7 +31,7 @@ gulp.task('startservers:test', ['webpack:dev', 'static:dev', 'css:dev'], () => { children.push(cp.fork('server.js')); children.push(cp.spawn('webdriver-manager', ['start'])); children.push(cp.spawn('mongod', ['--dbpath=./db'])); - children.push(cp.fork('../', [], {env: {MONGO_URI: mongoUri}})); + children.push(cp.fork('../../week_3//rest_api/heidilaursen/server/server.js', [], {env: {MONGO_URI: mongoUri}})); }); // gulp.task('startServers:develop', ['webpack:dev', 'static:dev', 'css:dev'], () => { diff --git a/test/ang-spec.js b/test/ang-spec.js index eb6e9f2..bf6c6c7 100644 --- a/test/ang-spec.js +++ b/test/ang-spec.js @@ -1,6 +1,6 @@ describe('our super awesome angular app', function() { it('should have a 2 way data binding', () => { - browser.get('http://localhost:4020'); + browser.get('http://localhost:4030'); element(by.model('greeting')).sendKeys('hello world'); element(by.id('greeting')).getText().then(function(text) { expect(text).toEqual('hello world'); From ac1d8955614e46ef99ac96437ed4a6f02d68ce30 Mon Sep 17 00:00:00 2001 From: heidilaursen Date: Sun, 5 Jun 2016 19:16:17 -0700 Subject: [PATCH 9/9] fixed readme to run on gulp or npm start --- README.md | 18 ++++++------------ gulpfile.js | 15 --------------- package.json | 3 +-- 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 5fef4f5..dd1e6f6 100644 --- a/README.md +++ b/README.md @@ -10,23 +10,17 @@ Two Mongoose Schema models are created (resources) to route and manipulate throu ##Dev dependencies * Gulp - * Gulp-Eslint + * gulp-protractor * Webpack-stream ### How to test with protractor and selenium -In the first terminal: -``` -webdriver-manager start -``` -In a second terminal: -``` -node server.js -``` -In a third terminal: +Run a gulp command to bundle build, start server and run selenium and protractor: ``` gulp ``` -Run test with: +or ``` -protractor ./test/config.js +npm start ``` + +*Bella - the only concern I have for you running this, is the server I'm using for mongo in gulp is from my rest_api and I'm not sure it will exist for you? I followed Tyler's code on this. Please let me know if it's a problem and if you have any suggestions... diff --git a/gulpfile.js b/gulpfile.js index 7895fa8..a79fcc2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -34,21 +34,6 @@ gulp.task('startservers:test', ['webpack:dev', 'static:dev', 'css:dev'], () => { children.push(cp.fork('../../week_3//rest_api/heidilaursen/server/server.js', [], {env: {MONGO_URI: mongoUri}})); }); -// gulp.task('startServers:develop', ['webpack:dev', 'static:dev', 'css:dev'], () => { -// nodemon({ -// script: 'server.js', -// ext: 'html js css', -// ignore: ['build'], -// tasks: ['protractor'] -// }); -// }); - -// gulp.task('startServers:selenium', () => { -// exec('webdriver-manager start', (cb) => { -// cb(err); -// }); -// }); - gulp.task('protractor', ['startservers:test'], () => { gulp.src(['./test/*spec.js']) .pipe(protractor({ diff --git a/package.json b/package.json index 9f4ef4d..83a82c2 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "gulpfile.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "start": "node server.js" + "start": "gulp" }, "author": "", "license": "MIT", @@ -15,7 +15,6 @@ "devDependencies": { "angular": "^1.5.5", "gulp": "^3.9.1", - "gulp-nodemon": "^2.0.7", "gulp-protractor": "^2.4.0", "webpack-stream": "^3.2.0" }