Skip to content

Commit 9343669

Browse files
committed
feat(test): protractor integration, e2e test sample
1 parent a8ee48b commit 9343669

File tree

7 files changed

+86
-6
lines changed

7 files changed

+86
-6
lines changed

README.md

+18-4
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,33 @@ ng build
6767
The build artifacts will be stored in the `dist/` directory.
6868

6969

70-
### Running tests
70+
### Running unit tests
7171

72-
Before running the tests make sure that the project is built. To build the
72+
Before running the tests make sure that the project is built. To build the
7373
project once you can use:
7474

7575
```bash
7676
ng build
7777
```
7878

79-
With the project built in the `dist/` folder you can just run: `karma start`.
79+
With the project built in the `dist/` folder you can just run: `karma start`.
8080
Karma will run the tests and keep the browser open waiting to run again.
8181

82-
This will be easier when the command
82+
83+
### Running end-to-end tests
84+
85+
Before running the tests make sure that you have an updated webdriver and that
86+
the tests are built:
87+
88+
```bash
89+
$(npm bin)/webdriver-manager update
90+
$(npm bin)/tsc -p e2e/
91+
```
92+
93+
Afterwards you only need to run `$(npm bin)/protractor` while serving via
94+
`ng serve`.
95+
96+
This will be easier when the command
8397
[ng test](https://github.com/angular/angular-cli/issues/70) is implemented.
8498

8599

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import "angular2/testing";
2+
import { <%= jsComponentName %>Page } from './app.po';
3+
4+
describe('<%= htmlComponentName %> App', function() {
5+
let page: <%= jsComponentName %>Page;
6+
7+
beforeEach(() => {
8+
page = new <%= jsComponentName %>Page();
9+
})
10+
11+
it('should display message saying app works', () => {
12+
page.navigateTo()
13+
expect(page.getParagraphText()).toEqual('<%= htmlComponentName %> Works!');
14+
});
15+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import "angular2/testing";
2+
3+
export class <%= jsComponentName %>Page {
4+
navigateTo() { return browser.get('/'); }
5+
getParagraphText() { return element(by.css('<%= jsComponentName %>-app p')).getText(); }
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES5",
4+
"module": "commonjs",
5+
"sourceMap": true,
6+
"declaration": false,
7+
"emitDecoratorMetadata": true,
8+
"experimentalDecorators": true,
9+
"removeComments": false
10+
}
11+
}

addon/ng2/blueprints/ng2/files/gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@
1414
/coverage/*
1515
/libpeerconnection.log
1616
npm-debug.log
17-
testem.log
17+
testem.log
18+
19+
# e2e
20+
/e2e/*.js
21+
/e2e/*.map

addon/ng2/blueprints/ng2/files/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"jasmine-core": "^2.3.4",
1919
"karma": "^0.13.15",
2020
"karma-chrome-launcher": "^0.2.1",
21-
"karma-jasmine": "^0.3.6"
21+
"karma-jasmine": "^0.3.6",
22+
"protractor": "^3.0.0",
23+
"typescript": "^1.7.3"
2224
}
2325
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
exports.config = {
2+
allScriptsTimeout: 11000,
3+
4+
specs: [
5+
'e2e/**/*.e2e.js'
6+
],
7+
8+
capabilities: {
9+
'browserName': 'chrome'
10+
},
11+
12+
directConnect: true,
13+
14+
baseUrl: 'http://localhost:4200/',
15+
16+
framework: 'jasmine',
17+
18+
jasmineNodeOpts: {
19+
defaultTimeoutInterval: 30000
20+
},
21+
22+
useAllAngular2AppRoots: true,
23+
24+
beforeLaunch: function() {
25+
require('zone.js');
26+
require('reflect-metadata');
27+
}
28+
};

0 commit comments

Comments
 (0)