From 451268664824e19f22d4b979d11d1235989e7ce3 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Fri, 19 Feb 2016 15:38:46 +0000 Subject: [PATCH] feat(e2e): add ng e2e command --- addon/ng2/blueprints/ng2/files/e2e/app.e2e.ts | 3 ++- addon/ng2/blueprints/ng2/files/e2e/app.po.ts | 2 -- .../blueprints/ng2/files/e2e/tsconfig.json | 13 ++++++---- addon/ng2/blueprints/ng2/files/package.json | 8 +++++-- .../blueprints/ng2/files/protractor.conf.js | 24 +++++++++---------- addon/ng2/blueprints/ng2/files/typings.json | 7 +++--- addon/ng2/commands/e2e.js | 20 ++++++++++++++++ addon/ng2/index.js | 1 + addon/ng2/tasks/e2e.js | 12 ++++++++++ 9 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 addon/ng2/commands/e2e.js create mode 100644 addon/ng2/tasks/e2e.js diff --git a/addon/ng2/blueprints/ng2/files/e2e/app.e2e.ts b/addon/ng2/blueprints/ng2/files/e2e/app.e2e.ts index b299821de396..3414eee210c1 100644 --- a/addon/ng2/blueprints/ng2/files/e2e/app.e2e.ts +++ b/addon/ng2/blueprints/ng2/files/e2e/app.e2e.ts @@ -1,4 +1,5 @@ -import "angular2/testing"; +/// + import { <%= jsComponentName %>Page } from './app.po'; describe('<%= htmlComponentName %> App', function() { diff --git a/addon/ng2/blueprints/ng2/files/e2e/app.po.ts b/addon/ng2/blueprints/ng2/files/e2e/app.po.ts index 43e99b59c38c..f7ba4544a1cd 100644 --- a/addon/ng2/blueprints/ng2/files/e2e/app.po.ts +++ b/addon/ng2/blueprints/ng2/files/e2e/app.po.ts @@ -1,5 +1,3 @@ -import "angular2/testing"; - export class <%= jsComponentName %>Page { navigateTo() { return browser.get('/'); } getParagraphText() { return element(by.css('<%= jsComponentName %>-app p')).getText(); } diff --git a/addon/ng2/blueprints/ng2/files/e2e/tsconfig.json b/addon/ng2/blueprints/ng2/files/e2e/tsconfig.json index 304804ccabda..20f6192a996c 100644 --- a/addon/ng2/blueprints/ng2/files/e2e/tsconfig.json +++ b/addon/ng2/blueprints/ng2/files/e2e/tsconfig.json @@ -1,11 +1,16 @@ { "compilerOptions": { - "target": "ES5", - "module": "commonjs", - "sourceMap": true, "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, - "removeComments": false + "mapRoot": "", + "module": "system", + "moduleResolution": "node", + "noEmitOnError": true, + "noImplicitAny": false, + "rootDir": ".", + "sourceMap": true, + "sourceRoot": "/", + "target": "es5" } } diff --git a/addon/ng2/blueprints/ng2/files/package.json b/addon/ng2/blueprints/ng2/files/package.json index 3c2779f7b510..c19bd3aca274 100644 --- a/addon/ng2/blueprints/ng2/files/package.json +++ b/addon/ng2/blueprints/ng2/files/package.json @@ -12,7 +12,9 @@ "start": "ng server", "postinstall": "typings install --ambient", "lint": "tslint src/**/*.ts", - "format": "clang-format -i -style=file --glob=src/**/*.ts" + "format": "clang-format -i -style=file --glob=src/**/*.ts", + "pree2e": "webdriver-manager update", + "e2e": "protractor" }, "private": true, "dependencies": { @@ -30,12 +32,14 @@ "ember-cli-inject-live-reload": "^1.3.0", "glob": "^6.0.4", "jasmine-core": "^2.3.4", + "jasmine-spec-reporter": "^2.4.0", "karma": "^0.13.15", "karma-chrome-launcher": "^0.2.1", "karma-jasmine": "^0.3.6", "protractor": "^3.0.0", "tslint": "^3.3.0", "typescript": "^1.7.3", - "typings": "^0.6.6" + "typings": "^0.6.6", + "ts-node": "^0.5.5" } } diff --git a/addon/ng2/blueprints/ng2/files/protractor.conf.js b/addon/ng2/blueprints/ng2/files/protractor.conf.js index d51992dfd1b3..9ecaa467393f 100644 --- a/addon/ng2/blueprints/ng2/files/protractor.conf.js +++ b/addon/ng2/blueprints/ng2/files/protractor.conf.js @@ -1,28 +1,26 @@ +var SpecReporter = require('jasmine-spec-reporter'); + exports.config = { allScriptsTimeout: 11000, - specs: [ - 'e2e/**/*.e2e.js' + 'e2e/**/*.e2e.ts' ], - capabilities: { 'browserName': 'chrome' }, - directConnect: true, - baseUrl: 'http://localhost:4200/', - framework: 'jasmine', - jasmineNodeOpts: { - defaultTimeoutInterval: 30000 + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} }, - useAllAngular2AppRoots: true, - beforeLaunch: function() { - require('zone.js'); - require('reflect-metadata'); - } + require('ts-node/register'); + }, + onPrepare: function() { + jasmine.getEnv().addReporter(new SpecReporter()); + }, }; diff --git a/addon/ng2/blueprints/ng2/files/typings.json b/addon/ng2/blueprints/ng2/files/typings.json index 66c0b4ee23de..9760d097580e 100644 --- a/addon/ng2/blueprints/ng2/files/typings.json +++ b/addon/ng2/blueprints/ng2/files/typings.json @@ -1,9 +1,10 @@ { "dependencies": {}, - "devDependencies": { - }, + "devDependencies": {}, "ambientDevDependencies": { - "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#26c98c8a9530c44f8c801ccc3b2057e2101187ee" + "angular-protractor": "github:DefinitelyTyped/DefinitelyTyped/angular-protractor/angular-protractor.d.ts#17fa1e5f269189f7f8e0f53f8c443e6c2eac562c", + "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#26c98c8a9530c44f8c801ccc3b2057e2101187ee", + "selenium-webdriver": "github:DefinitelyTyped/DefinitelyTyped/selenium-webdriver/selenium-webdriver.d.ts#a83677ed13add14c2ab06c7325d182d0ba2784ea" }, "ambientDependencies": { "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2" diff --git a/addon/ng2/commands/e2e.js b/addon/ng2/commands/e2e.js new file mode 100644 index 000000000000..e2ae53a8a4a9 --- /dev/null +++ b/addon/ng2/commands/e2e.js @@ -0,0 +1,20 @@ +/* jshint node: true */ +'use strict'; + +var Command = require('ember-cli/lib/models/command'); +var E2ETask = require('../tasks/e2e'); + +module.exports = Command.extend({ + name: 'e2e', + description: 'Run e2e tests in existing project', + works: 'insideProject', + run: function() { + var e2eTask = new E2ETask({ + ui: this.ui, + analytics: this.analytics, + project: this.project + }); + + return e2eTask.run(); + } +}); diff --git a/addon/ng2/index.js b/addon/ng2/index.js index 59d3bacb6e1e..8d325803d4d7 100644 --- a/addon/ng2/index.js +++ b/addon/ng2/index.js @@ -10,6 +10,7 @@ module.exports = { 'install' : require('./commands/install'), 'uninstall' : require('./commands/uninstall'), 'test' : require('./commands/test'), + 'e2e' : require('./commands/e2e'), 'lint' : require('./commands/lint'), 'format' : require('./commands/format') }; diff --git a/addon/ng2/tasks/e2e.js b/addon/ng2/tasks/e2e.js new file mode 100644 index 000000000000..a78151b30172 --- /dev/null +++ b/addon/ng2/tasks/e2e.js @@ -0,0 +1,12 @@ +/* jshint node: true */ +'use strict'; + +var Promise = require('ember-cli/lib/ext/promise'); +var Task = require('ember-cli/lib/models/task'); +var exec = Promise.denodeify(require('shelljs').exec); + +module.exports = Task.extend({ + run: function() { + return exec('npm run e2e'); + } +});