Commit 168495d7 authored by Ward Bell's avatar Ward Bell

chore: smooth the protractor process; shuffle scripts in package.json

parent 62f89159
...@@ -4,3 +4,4 @@ node_modules/ ...@@ -4,3 +4,4 @@ node_modules/
*.js.map *.js.map
!**/*e2e-spec.js !**/*e2e-spec.js
_test-output _test-output
protractor-results.txt
...@@ -128,6 +128,10 @@ we configured protractor to find them. ...@@ -128,6 +128,10 @@ we configured protractor to find them.
Thereafter, run them with `npm run e2e`. Thereafter, run them with `npm run e2e`.
That command first compiles, then simultaneously starts the Http-Server at `localhost:8080` That command first compiles, then simultaneously starts the Http-Server at `localhost:8080`
and launches protractor. The pass/fail test results appear at the bottom of the terminal window. and launches protractor.
The pass/fail test results appear at the bottom of the terminal window.
A custom reporter (see `protractor.config.js`) generates a `./protractor-results.txt` file
which is easier to read; this file is excluded from source control.
Shut it down manually with Ctrl-C. Shut it down manually with Ctrl-C.
{ {
"name": "angular2-quickstart", "name": "angular2-quickstart",
"version": "1.0.0", "version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": { "scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ", "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"build-and-test": "npm run tsc && npm run test",
"docker-build": "docker build -t ng2-quickstart .", "docker-build": "docker build -t ng2-quickstart .",
"docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart", "docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart",
"e2e": "tsc && concurrently \"http-server\" \"protractor protractor.config.js\"", "e2e": "tsc && concurrently \"http-server\" \"protractor protractor.config.js\"",
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server", "lite": "lite-server",
"postinstall": "typings install",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"", "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings", "typings": "typings",
"webdriver:update": "webdriver-manager update", "webdriver:update": "webdriver-manager update"
"postinstall": "typings install"
}, },
"keywords": [],
"author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"angular2": "2.0.0-beta.15", "angular2": "2.0.0-beta.15",
"a2-in-memory-web-api": "^0.1.15",
"systemjs": "0.19.26", "systemjs": "0.19.26",
"es6-shim": "^0.35.0", "es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2", "reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2", "rxjs": "5.0.0-beta.2",
"zone.js": "0.6.10" "zone.js": "0.6.10",
"a2-in-memory-web-api": "^0.1.15"
}, },
"devDependencies": { "devDependencies": {
"canonical-path": "0.0.2", "canonical-path": "0.0.2",
...@@ -41,5 +43,6 @@ ...@@ -41,5 +43,6 @@
"rimraf": "^2.5.2", "rimraf": "^2.5.2",
"typescript": "^1.8.10", "typescript": "^1.8.10",
"typings":"^0.7.12" "typings":"^0.7.12"
} },
"repository": { }
} }
...@@ -47,25 +47,7 @@ exports.config = { ...@@ -47,25 +47,7 @@ exports.config = {
// debugging // debugging
// console.log('browser.params:' + JSON.stringify(browser.params)); // console.log('browser.params:' + JSON.stringify(browser.params));
var appDir = browser.params.appDir;
if (appDir) {
if (appDir.match('/ts') != null) {
browser.appIsTs = true;
} else if (appDir.match('/js') != null) {
browser.appIsJs = true;
} else if (appDir.match('/dart') != null) {
browser.appIsDart = true;
} else {
browser.appIsUnknown = true;
}
} else {
browser.appIsUnknown = true;
}
jasmine.getEnv().addReporter(new Reporter( browser.params )) ; jasmine.getEnv().addReporter(new Reporter( browser.params )) ;
global.describeIf = describeIf;
global.itIf = itIf;
global.sendKeys = sendKeys;
// Allow changing bootstrap mode to NG1 for upgrade tests // Allow changing bootstrap mode to NG1 for upgrade tests
global.setProtractorToNg1Mode = function() { global.setProtractorToNg1Mode = function() {
...@@ -82,22 +64,6 @@ exports.config = { ...@@ -82,22 +64,6 @@ exports.config = {
} }
}; };
function describeIf(cond, name, func) {
if (cond) {
describe(name, func);
} else {
xdescribe(name, func);
}
}
function itIf(cond, name, func) {
if (cond) {
it(name, func);
} else {
xit(name, func);
}
}
// Hack - because of bug with send keys // Hack - because of bug with send keys
function sendKeys(element, str) { function sendKeys(element, str) {
return str.split('').reduce(function (promise, char) { return str.split('').reduce(function (promise, char) {
...@@ -108,11 +74,13 @@ function sendKeys(element, str) { ...@@ -108,11 +74,13 @@ function sendKeys(element, str) {
// better to create a resolved promise here but ... don't know how with protractor; // better to create a resolved promise here but ... don't know how with protractor;
} }
// Custom reporter
function Reporter(options) { function Reporter(options) {
var _defaultOutputFile = path.resolve(process.cwd(), "../../", 'protractor-results.txt'); var _defaultOutputFile = path.resolve(process.cwd(), './', 'protractor-results.txt');
options.outputFile = options.outputFile || _defaultOutputFile; options.outputFile = options.outputFile || _defaultOutputFile;
initOutputFile(options.outputFile);
options.appDir = options.appDir || './';
var _root = { appDir: options.appDir, suites: [] }; var _root = { appDir: options.appDir, suites: [] };
log('AppDir: ' + options.appDir, +1); log('AppDir: ' + options.appDir, +1);
var _currentSuite; var _currentSuite;
...@@ -159,6 +127,11 @@ function Reporter(options) { ...@@ -159,6 +127,11 @@ function Reporter(options) {
fs.appendFileSync(outputFile, output); fs.appendFileSync(outputFile, output);
}; };
function initOutputFile(outputFile) {
var header = "Protractor results for: " + (new Date()).toLocaleString() + "\n\n";
fs.writeFileSync(outputFile, header);
}
// for output file output // for output file output
function formatOutput(output) { function formatOutput(output) {
var indent = ' '; var indent = ' ';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment