diff --git a/.gitignore b/.gitignore index 5915f41..d664fb7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules/ *.js.map !**/*e2e-spec.js _test-output +protractor-results.txt diff --git a/README.md b/README.md index c9fa68c..8b3fba1 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,10 @@ we configured protractor to find them. Thereafter, run them with `npm run e2e`. 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. diff --git a/package.json b/package.json index 0b30886..3fb4093 100644 --- a/package.json +++ b/package.json @@ -1,30 +1,32 @@ { "name": "angular2-quickstart", "version": "1.0.0", + "description": "QuickStart package.json from the documentation, supplemented with testing support", "scripts": { "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ", - "build-and-test": "npm run tsc && npm run test", "docker-build": "docker build -t 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\"", - "tsc": "tsc", - "tsc:w": "tsc -w", "lite": "lite-server", + "postinstall": "typings install", "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"", + "tsc": "tsc", + "tsc:w": "tsc -w", "typings": "typings", - "webdriver:update": "webdriver-manager update", - "postinstall": "typings install" + "webdriver:update": "webdriver-manager update" }, + "keywords": [], + "author": "", "license": "ISC", "dependencies": { "angular2": "2.0.0-beta.15", - "a2-in-memory-web-api": "^0.1.15", - "systemjs": "0.19.26", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.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": { "canonical-path": "0.0.2", @@ -41,5 +43,6 @@ "rimraf": "^2.5.2", "typescript": "^1.8.10", "typings":"^0.7.12" - } + }, + "repository": { } } diff --git a/protractor.config.js b/protractor.config.js index 0caadc0..d4ad9d3 100644 --- a/protractor.config.js +++ b/protractor.config.js @@ -47,25 +47,7 @@ exports.config = { // debugging // 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 )) ; - global.describeIf = describeIf; - global.itIf = itIf; - global.sendKeys = sendKeys; // Allow changing bootstrap mode to NG1 for upgrade tests global.setProtractorToNg1Mode = function() { @@ -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 function sendKeys(element, str) { return str.split('').reduce(function (promise, char) { @@ -108,11 +74,13 @@ function sendKeys(element, str) { // better to create a resolved promise here but ... don't know how with protractor; } - +// Custom reporter 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; + initOutputFile(options.outputFile); + options.appDir = options.appDir || './'; var _root = { appDir: options.appDir, suites: [] }; log('AppDir: ' + options.appDir, +1); var _currentSuite; @@ -159,6 +127,11 @@ function Reporter(options) { 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 function formatOutput(output) { var indent = ' ';