Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test): protractor integration, e2e test sample #94

Merged
merged 1 commit into from
Jan 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
15 changes: 15 additions & 0 deletions addon/ng2/blueprints/ng2/files/e2e/app.e2e.ts
Original file line number Diff line number Diff line change
@@ -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!');
});
});
6 changes: 6 additions & 0 deletions addon/ng2/blueprints/ng2/files/e2e/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "angular2/testing";

export class <%= jsComponentName %>Page {
navigateTo() { return browser.get('/'); }
getParagraphText() { return element(by.css('<%= jsComponentName %>-app p')).getText(); }
}
11 changes: 11 additions & 0 deletions addon/ng2/blueprints/ng2/files/e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false
}
}
4 changes: 4 additions & 0 deletions addon/ng2/blueprints/ng2/files/gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
/libpeerconnection.log
npm-debug.log
testem.log

# e2e
/e2e/*.js
/e2e/*.map
4 changes: 3 additions & 1 deletion addon/ng2/blueprints/ng2/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
28 changes: 28 additions & 0 deletions addon/ng2/blueprints/ng2/files/protractor.conf.js
Original file line number Diff line number Diff line change
@@ -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');
}
};