Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
chore(env): environment vars for typescript and javascript examples (#26
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cnishina committed Jan 4, 2017
1 parent 257aab6 commit fae9378
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 47 deletions.
7 changes: 5 additions & 2 deletions protractor-javascript/environment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
baseUrl: (process.env.BASE_URL || 'http://localhost:8080')
var baseUrl = (process.env.BASE_URL || 'http://localhost:8080');
var url = baseUrl;
if (baseUrl !== 'http://localhost:8080') {
url += '/protractor-cookbook';
}
exports.url = url;
12 changes: 1 addition & 11 deletions protractor-javascript/example-browserlog/conf.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
var env = require('../environment');

// Tests for the calculator.
exports.config = {
directConnect: true,

specs: [
'spec.js'
],

framework: 'jasmine2',

capabilities: {
'browserName': 'chrome'
},

baseUrl: env.baseUrl
}
};
4 changes: 3 additions & 1 deletion protractor-javascript/example-browserlog/spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
var env = require('../environment');

describe('slow calculator', () => {
var firstNum = element(by.model('first'));
var secondNum = element(by.model('second'));
var goButton = element(by.id('gobutton'));
var result = element(by.binding('latest'));

beforeEach(() => {
browser.get('/ng1/calculator');
browser.get(env.url + '/ng1/calculator');
});

afterEach(() => {
Expand Down
7 changes: 1 addition & 6 deletions protractor-javascript/example/conf.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
var env = require('../environment');

// Tests for the calculator.
exports.config = {
directConnect: true,
capabilities: {
'browserName': 'chrome'
},
specs: [
'spec.js'
],
baseUrl: env.baseUrl,
framework: 'jasmine2'
]
};
4 changes: 3 additions & 1 deletion protractor-javascript/example/spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var env = require('../environment');

describe('slow calculator', () => {
beforeEach(() => {
browser.get('/ng1/calculator');
browser.get(env.url + '/ng1/calculator');
});

it('should add numbers', () => {
Expand Down
17 changes: 10 additions & 7 deletions protractor-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
"version": "1.0.0",
"description": "from https://github.com/juliemr/protractor-demo",
"scripts": {
"pretest": "webdriver-manager update",
"test-browserlog": "protractor example-browserlog/conf.js",
"test-example": "protractor example/conf.js",
"test-network": "protractor example-network/conf.js",
"test-screenshot": "protractor example-screenshot/conf.js",
"test": "npm run test-browserlog && npm run test-example && npm run test-network"
"example": "protractor example/conf.js",
"example-browserlog": "protractor example-browserlog/conf.js",
"example-network": "protractor example-network/conf.js",
"example-screenshot": "protractor example-screenshot/conf.js",
"pretest": "webdriver-manager update --gecko false",
"start": "cd ../testapp && npm install && npm start",
"test": "npm run example-browserlog && npm run example && npm run example-network",
"test-external": "export BASE_URL='http://angular.github.io' && npm test",
"text-local": "unset BASE_URL && npm test"
},
"author": "",
"license": "MIT",
"dependencies": {
"mkdirp": "^0.5.1",
"protractor": "4.0.9"
"protractor": "4.0.14"
}
}
7 changes: 7 additions & 0 deletions protractor-typescript/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export let baseUrl = (process.env.BASE_URL || 'http://localhost:8080');
export let url = baseUrl;

url = baseUrl;
if (url !== 'http://localhost:8080') {
url += '/protractor-cookbook';
}
5 changes: 1 addition & 4 deletions protractor-typescript/example-on-prepare/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { ProtractorBrowser, Config } from 'protractor';
import { browser, Config } from 'protractor';

export let config: Config = {
directConnect: true,
specs: [ '../spec.js' ],
onPrepare: () => {
let globals = require('protractor');
let browser = globals.browser;
browser.manage().window().maximize();
browser.manage().timeouts().implicitlyWait(5000);
}
Expand Down
1 change: 0 additions & 1 deletion protractor-typescript/example/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Config} from 'protractor';

export let config: Config = {
directConnect: true,
specs: [ '../spec.js' ]
}
22 changes: 11 additions & 11 deletions protractor-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
"name": "protractor-typescript",
"version": "1.0.0",
"description": "a protractor with typescript example",
"main": "conf.js",
"scripts": {
"pretest": "npm run tsc && webdriver-manager update",
"test": "npm run test-example && npm run test-example-on-prepare",
"test-example": "protractor tmp/example/config.js",
"test-example-on-prepare": "protractor tmp/example-on-prepare/config.js",
"tsc": "tsc"
"example": "protractor tmp/example/config.js",
"example-on-prepare": "protractor tmp/example-on-prepare/config.js",
"pretest": "tsc && webdriver-manager update --gecko false",
"start": "cd ../testapp && npm install && npm start",
"test": "npm run example && npm run example-on-prepare",
"test-external": "export BASE_URL='http://angular.github.io' && npm test",
"test-local": "unset BASE_URL && npm test"
},
"author": "Craig Nishina <craig.nishina@gmail.com>",
"license": "MIT",
"dependencies": {
"jasmine": "^2.4.1",
"protractor": "4.0.9",
"typescript": "^2.0.0"
"protractor": "4.0.14",
"typescript": "^2.1.4"
},
"devDependencies": {
"@types/jasmine": "^2.2.31",
"@types/node": "^6.0.35"
"@types/jasmine": "^2.5.40",
"@types/node": "^6.0.54"
}
}
6 changes: 3 additions & 3 deletions protractor-typescript/spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ElementFinder, browser, by, element } from 'protractor';
import * as env from './environment';

describe('slow calculator', () => {
beforeEach(() => {
// browser.get('http://angular.github.io/protractor-cookbook/ng1/calculator/');
browser.get('http://localhost:8080/ng1/calculator/');
browser.get(env.url + '/ng1/calculator/');
});

it('should add numbers', () => {
Expand All @@ -18,7 +18,7 @@ describe('slow calculator', () => {
let first: ElementFinder;
let second: ElementFinder;
let goButton: ElementFinder;

beforeEach(() => {
first = element(by.model('first'));
second = element(by.model('second'));
Expand Down

0 comments on commit fae9378

Please sign in to comment.