Skip to content

Commit

Permalink
added initial e2e and server side tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mau11 committed Jan 6, 2017
1 parent 44b5091 commit dc06835
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
.elasticbeanstalk/
.jshintrc
./public/bundle.js
npm-debug.log
20 changes: 20 additions & 0 deletions clientTests/e2e/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// To run this test, enter
// $ npm run client
describe('Emanie (prior to log in)', function() {

it('should load page', function (client, done) {
client
.url('http://localhost:8000')
.waitForElementVisible('body', 1000)
.assert.title('Emanie') // remove this
.assert.visible('.navbar-inverse')
.assert.visible('.form.control')
.pause(1000);
});

after(function(client, done) {
client.end(function() {
done();
});
});
});
37 changes: 37 additions & 0 deletions nightwatch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"src_folders" : ["clientTests/e2e/client.js"],
"output_folder" : "clientTests/reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "clientTests/pages",
"globals_path" : "",

"selenium" : {
"start_process" : true,
"server_path" : "./node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar",
"log_path" : "",
"host": "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver": "./node_modules/selenium-standalone/.selenium/chromedriver/2.25-x64-chromedriver"
}
},

"test_runner" : "mocha",
"test_settings" : {
"default" : {
"launch_url" : "http://localhost:8000",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : "clientTests/screenshots"
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true
}
}
}
}
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "",
"main": "index.html",
"scripts": {
"test": "test",
"client": "node node_modules/nightwatch/bin/nightwatch",
"test": "mocha serverTests/test/serverTests.js",
"start": "webpack-dev-server --inline --hot",
"dev": "webpack-dev-server --content-base public --inline --hot"
},
Expand All @@ -29,7 +30,11 @@
"jshint-loader": "^0.8.3",
"json-loader": "^0.5.4",
"mocha": "^3.2.0",
"node-libs-browser": "^2.0.0"
"nightwatch": "^0.9.12",
"node-libs-browser": "^2.0.0",
"selenium-standalone": "^5.9.0",
"should": "^11.1.2",
"supertest": "^2.0.1"
},
"dependencies": {
"auth0-lock": "^10.8.0",
Expand Down
16 changes: 16 additions & 0 deletions serverTests/test/serverTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var should = require('should');
var supertest = require('supertest');
var server = supertest.agent('http://localhost:8000');

// Start up server prior to running test.
describe('server',function(){
it('should connect to server', function(done){
server
.get('/')
.expect(200)
.end(function(err,res){
res.status.should.equal(200);
done();
});
});
});

0 comments on commit dc06835

Please sign in to comment.