From 4862a61af3a43538674299b0fc05c61748bbfd10 Mon Sep 17 00:00:00 2001 From: Pavel Reznikov Date: Tue, 1 Mar 2016 19:31:09 -0800 Subject: [PATCH] protractor e2e test --- .gitignore | 3 ++- .travis.yml | 37 +++++++++++++++++++++++++++++++------ Gruntfile.js | 20 ++++++++++++++++++++ package.json | 6 +++++- protractor.conf.js | 9 +++++++++ spec/e2e/gridstack-spec.js | 13 +++++++++++++ 6 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 protractor.conf.js create mode 100644 spec/e2e/gridstack-spec.js diff --git a/.gitignore b/.gitignore index 186552a..95ec03e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules bower_components -coverage \ No newline at end of file +coverage +*.log diff --git a/.travis.yml b/.travis.yml index d5a0729..f98fae5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,36 @@ language: node_js +node_js: + - "5.7.0" + +env: + - CXX=g++-4.8 + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 + +before_install: + - npm install -g protractor + +install: + - npm install -g npm@2 + - npm install -g grunt-cli + - npm install -g bower + - bower install + - npm install + - webdriver-manager update --standalone + before_script: -- npm install -g grunt-cli -- npm install -g bower -- bower install -- npm install + - export CHROME_BIN=chromium-browser + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - nohup bash -c "webdriver-manager start 2>&1 &" script: -- npm run build -- npm test \ No newline at end of file + - npm run build + - npm test + - grunt e2e-test diff --git a/Gruntfile.js b/Gruntfile.js index 6404f1d..8ce7511 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,6 +7,8 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-jscs'); grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-protractor-runner'); + grunt.loadNpmTasks('grunt-contrib-connect'); grunt.initConfig({ sass: { @@ -95,7 +97,25 @@ module.exports = function(grunt) { }, }, }, + + protractor: { + options: { + configFile: 'protractor.conf.js', + }, + all: {} + }, + + connect: { + all: { + options: { + port: 8080, + hostname: 'localhost', + base: '.', + }, + }, + }, }); grunt.registerTask('default', ['sass', 'cssmin', 'jshint', 'jscs', 'copy', 'uglify', 'doctoc']); + grunt.registerTask('e2e-test', ['connect', 'protractor']); }; diff --git a/package.json b/package.json index 1f7d673..bdbb69d 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,10 @@ "lodash": "^4.5.1" }, "devDependencies": { + "connect": "^3.4.1", "coveralls": "^2.11.6", "grunt": "^0.4.5", + "grunt-contrib-connect": "^0.11.2", "grunt-contrib-copy": "^0.8.2", "grunt-contrib-cssmin": "^0.14.0", "grunt-contrib-jshint": "^1.0.0", @@ -39,6 +41,7 @@ "grunt-contrib-watch": "^0.6.1", "grunt-doctoc": "^0.1.1", "grunt-jscs": "^2.7.0", + "grunt-protractor-runner": "^3.0.0", "grunt-sass": "^1.1.0", "jasmine-core": "^2.4.1", "karma": "^0.13.21", @@ -46,6 +49,7 @@ "karma-coveralls": "^1.1.2", "karma-jasmine": "^0.3.7", "karma-phantomjs-launcher": "^1.0.0", - "phantomjs": "^2.1.3" + "phantomjs-prebuilt": "^2.1.4", + "serve-static": "^1.10.2" } } diff --git a/protractor.conf.js b/protractor.conf.js new file mode 100644 index 0000000..52a0b5a --- /dev/null +++ b/protractor.conf.js @@ -0,0 +1,9 @@ +exports.config = { + seleniumAddress: 'http://localhost:4444/wd/hub', + specs: ['spec/e2e/*-spec.js'], + capabilities: { + browserName: 'firefox', + version: '', + platform: 'ANY' + }, +}; diff --git a/spec/e2e/gridstack-spec.js b/spec/e2e/gridstack-spec.js new file mode 100644 index 0000000..859268e --- /dev/null +++ b/spec/e2e/gridstack-spec.js @@ -0,0 +1,13 @@ +describe('gridstack.js two grids demo', function() { + beforeAll(function() { + browser.ignoreSynchronization = true; + }); + + beforeEach(function() { + browser.get('http://localhost:8080/demo/two.html'); + }); + + it('should have proper title', function() { + expect(browser.getTitle()).toEqual('Two grids demo'); + }); +});