Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests #4

Merged
merged 4 commits into from
Jan 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`

Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
}
}
20 changes: 20 additions & 0 deletions test/conf.js
Original file line number Diff line number Diff line change
@@ -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
}
};
33 changes: 33 additions & 0 deletions test/spec.js
Original file line number Diff line number Diff line change
@@ -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');
});

});