diff --git a/README.md b/README.md index 9d35418d1521..7cd3bb7ae7db 100644 --- a/README.md +++ b/README.md @@ -69,19 +69,33 @@ ng build The build artifacts will be stored in the `dist/` directory. -### Running tests +### Running unit tests -Before running the tests make sure that the project is built. To build the +Before running the tests make sure that the project is built. To build the project once you can use: ```bash ng build ``` -With the project built in the `dist/` folder you can just run: `karma start`. +With the project built in the `dist/` folder you can just run: `karma start`. Karma will run the tests and keep the browser open waiting to run again. -This will be easier when the command + +### Running end-to-end tests + +Before running the tests make sure that you have an updated webdriver and that +the tests are built: + +```bash +$(npm bin)/webdriver-manager update +$(npm bin)/tsc -p e2e/ +``` + +Afterwards you only need to run `$(npm bin)/protractor` while serving via +`ng serve`. + +This will be easier when the command [ng test](https://github.com/angular/angular-cli/issues/70) is implemented. diff --git a/addon/ng2/blueprints/ng2/files/e2e/app.e2e.ts b/addon/ng2/blueprints/ng2/files/e2e/app.e2e.ts new file mode 100644 index 000000000000..b299821de396 --- /dev/null +++ b/addon/ng2/blueprints/ng2/files/e2e/app.e2e.ts @@ -0,0 +1,15 @@ +import "angular2/testing"; +import { <%= jsComponentName %>Page } from './app.po'; + +describe('<%= htmlComponentName %> App', function() { + let page: <%= jsComponentName %>Page; + + beforeEach(() => { + page = new <%= jsComponentName %>Page(); + }) + + it('should display message saying app works', () => { + page.navigateTo() + expect(page.getParagraphText()).toEqual('<%= htmlComponentName %> Works!'); + }); +}); diff --git a/addon/ng2/blueprints/ng2/files/e2e/app.po.ts b/addon/ng2/blueprints/ng2/files/e2e/app.po.ts new file mode 100644 index 000000000000..43e99b59c38c --- /dev/null +++ b/addon/ng2/blueprints/ng2/files/e2e/app.po.ts @@ -0,0 +1,6 @@ +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 new file mode 100644 index 000000000000..304804ccabda --- /dev/null +++ b/addon/ng2/blueprints/ng2/files/e2e/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "ES5", + "module": "commonjs", + "sourceMap": true, + "declaration": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "removeComments": false + } +} diff --git a/addon/ng2/blueprints/ng2/files/gitignore b/addon/ng2/blueprints/ng2/files/gitignore index a116e557f994..95838a42f765 100644 --- a/addon/ng2/blueprints/ng2/files/gitignore +++ b/addon/ng2/blueprints/ng2/files/gitignore @@ -18,3 +18,7 @@ /libpeerconnection.log npm-debug.log testem.log + +# e2e +/e2e/*.js +/e2e/*.map diff --git a/addon/ng2/blueprints/ng2/files/package.json b/addon/ng2/blueprints/ng2/files/package.json index cda74ecc2687..633721623ef6 100644 --- a/addon/ng2/blueprints/ng2/files/package.json +++ b/addon/ng2/blueprints/ng2/files/package.json @@ -25,6 +25,8 @@ "jasmine-core": "^2.3.4", "karma": "^0.13.15", "karma-chrome-launcher": "^0.2.1", - "karma-jasmine": "^0.3.6" + "karma-jasmine": "^0.3.6", + "protractor": "^3.0.0", + "typescript": "^1.7.3" } } diff --git a/addon/ng2/blueprints/ng2/files/protractor.conf.js b/addon/ng2/blueprints/ng2/files/protractor.conf.js new file mode 100644 index 000000000000..d51992dfd1b3 --- /dev/null +++ b/addon/ng2/blueprints/ng2/files/protractor.conf.js @@ -0,0 +1,28 @@ +exports.config = { + allScriptsTimeout: 11000, + + specs: [ + 'e2e/**/*.e2e.js' + ], + + capabilities: { + 'browserName': 'chrome' + }, + + directConnect: true, + + baseUrl: 'http://localhost:4200/', + + framework: 'jasmine', + + jasmineNodeOpts: { + defaultTimeoutInterval: 30000 + }, + + useAllAngular2AppRoots: true, + + beforeLaunch: function() { + require('zone.js'); + require('reflect-metadata'); + } +};