Skip to content

Commit a0c26a3

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

File tree

7 files changed

+85
-5
lines changed

7 files changed

+85
-5
lines changed

README.md

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

7171

72-
### Running tests
72+
### Running unit tests
7373

74-
Before running the tests make sure that the project is built. To build the
74+
Before running the tests make sure that the project is built. To build the
7575
project once you can use:
7676

7777
```bash
7878
ng build
7979
```
8080

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

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

87101

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

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
/libpeerconnection.log
1919
npm-debug.log
2020
testem.log
21+
22+
# e2e
23+
/e2e/*.js
24+
/e2e/*.map

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"jasmine-core": "^2.3.4",
2626
"karma": "^0.13.15",
2727
"karma-chrome-launcher": "^0.2.1",
28-
"karma-jasmine": "^0.3.6"
28+
"karma-jasmine": "^0.3.6",
29+
"protractor": "^3.0.0",
30+
"typescript": "^1.7.3"
2931
}
3032
}
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)