From 34912a7e7fe7e21cf271f6f1c3d6a80d6338dbc3 Mon Sep 17 00:00:00 2001 From: Marketionist Date: Tue, 3 Jan 2017 08:21:48 +0200 Subject: [PATCH 1/4] Added tests --- test/conf.js | 20 ++++++++++++++++++++ test/spec.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/conf.js create mode 100644 test/spec.js diff --git a/test/conf.js b/test/conf.js new file mode 100644 index 0000000..190aa71 --- /dev/null +++ b/test/conf.js @@ -0,0 +1,20 @@ +exports.config = { + directConnect: true, + + framework: 'jasmine2', + + specs: [ + 'spec.js' + ], + + capabilities: { + 'browserName': 'chrome' + }, + + onPrepare: function () { + global.numerator = require('../index.js').numerator; + protractor.ElementArrayFinder.prototype = Object.assign( + protractor.ElementArrayFinder.prototype, numerator); + // Some other code that needs to be executed before all tests + } +}; diff --git a/test/spec.js b/test/spec.js new file mode 100644 index 0000000..a8de8c9 --- /dev/null +++ b/test/spec.js @@ -0,0 +1,33 @@ +describe('protractor-numerator tests', function () { + beforeAll(function () { + // Turn off Angular synchronization + browser.ignoreSynchronization = true; + // Output some information about current tests process + console.log(`==> Tests running at: ${process.cwd()}`); + console.log(`==> With argv: ${process.argv}`); + }); + + beforeEach(function () { + browser.get('https://github.com/'); + }); + + it('should get the first link from the Github main page footer', function () { + let linkFooterContactGitHub = element.all(by.css('.site-footer-links > li')).first(); + + expect(linkFooterContactGitHub.getText()).toBe('Contact GitHub'); + }); + + it('should get the second link from the Github main page footer', function () { + let linkFooterAPI = element.all(by.xpath( + '//li[ancestor::*[contains(@class, "site-footer-links")]]')).second(); + + expect(linkFooterAPI.getText()).toBe('API'); + }); + + it('should get the third link from the Github main page footer', function () { + let linkFooterTraining = element.all(by.css('.site-footer-links > li')).third(); + + expect(linkFooterTraining.getText()).toBe('Training'); + }); + +}); From 5fe5065d4a47d1fec34f31072487e7bd35439a1f Mon Sep 17 00:00:00 2001 From: Marketionist Date: Tue, 3 Jan 2017 08:23:13 +0200 Subject: [PATCH 2/4] Bumped up package version to 0.3.0 --- package.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5c5d4e2..8c98bc2 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "protractor-numerator", - "version": "0.2.0", + "version": "0.3.0", "description": "Readable numeration for elements in Protractor tests", "main": "index.js", "scripts": { - "test": "echo \"[protractor-numerator] tests\"" + "postinstall": "webdriver-manager update", + "test": "node_modules/.bin/protractor test/conf.js" }, "repository": { "type": "git", @@ -25,5 +26,8 @@ "bugs": { "url": "https://github.com/Marketionist/protractor-numerator/issues" }, - "homepage": "https://github.com/Marketionist/protractor-numerator#readme" + "homepage": "https://github.com/Marketionist/protractor-numerator#readme", + "devDependencies": { + "protractor": "^4.0.14" + } } From 5a781fb174cfaa5a78b8008f68352ca957137c49 Mon Sep 17 00:00:00 2001 From: Marketionist Date: Tue, 3 Jan 2017 08:25:14 +0200 Subject: [PATCH 3/4] Added .travis.yml to run tests on Travis CI --- .travis.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c234cac --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +# http://docs.travis-ci.com/user/workers/container-based-infrastructure/ +sudo: required +dist: trusty + +# http://docs.travis-ci.com/user/languages/javascript-with-nodejs/ +language: node_js +node_js: + - "6" + - "7" + +# http://docs.travis-ci.com/user/gui-and-headless-browsers +before_install: + - export CHROME_BIN=/usr/bin/google-chrome + # start xvbfb for e2e tests with screen resolution 1280x1024x16 + - "export DISPLAY=:99.0" + - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16" + # give xvfb some time to start + - sleep 3 + - sudo apt-get update + - sudo apt-get install -y libappindicator1 fonts-liberation + - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb + - sudo dpkg -i google-chrome*.deb + - google-chrome --version + +install: + - npm install + +# http://docs.travis-ci.com/user/pull-requests/ +script: + - npm test From db51f8c96768b2f746d719f4c7f2184f0ba1ffe3 Mon Sep 17 00:00:00 2001 From: Marketionist Date: Tue, 3 Jan 2017 08:58:52 +0200 Subject: [PATCH 4/4] Updated README.md with supported versions and badges --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index c45453e..d2b4d7e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ # protractor-numerator + +[![Build Status](https://travis-ci.org/Marketionist/protractor-numerator.svg?branch=master)](https://travis-ci.org/Marketionist/protractor-numerator) +[![npm version](https://img.shields.io/npm/v/protractor-numerator.svg)](https://www.npmjs.com/package/protractor-numerator) +[![NPM License](https://img.shields.io/npm/l/protractor-numerator.svg)](https://github.com/Marketionist/protractor-numerator/blob/master/LICENSE) + This module adds readable numeration for elements in Protractor tests +## Supported versions +[Node.js](http://nodejs.org/): +- 6.x +- 7.x + +[Protractor](https://www.npmjs.com/package/protractor): +- 4.x + ## Installation `npm install protractor-numerator --save-dev`